Randal L. Schwartz schrieb:
"Birgit" == Birgit Kellner <[EMAIL PROTECTED]> writes:

Birgit> Hi,
Birgit> I'm looping through an array of hashes with "foreach" and have problems 
using
Birgit> "loop.last":

Birgit> <p>
Birgit> <% foreach record in record_list %>
Birgit> <% record_lastname %>, <% record.firstname %><% if not loop.last%>; <% end 
%>
Birgit> <% end %>:
Birgit> </p>

Birgit> However, the Template module throws an error:
Birgit> file error - parse error - pub_author.tmpl line 3: unexpected token 
(LAST) [%
Birgit> if not loop.last %].

Birgit> The same error is thrown by "unless loop.last".

Birgit> Can someone please explain this to me?

Unless you've done something other than just change your delimiters
away from [% %] to <% %>, the keywords are also (mostly) case-sensitive.
So you want things like:

<% FOREACH record IN record_list %>

etc.

Randal,

thanks, but that's not the problem. I'm calling the module with the "anycase" option enabled.

$tt = Template->new( { INCLUDE_PATH => $vars->{self_path}."/" . "template" , TAG_STYLE => 'asp', ANYCASE => 1}) || die("$!");

Besides, if it were the problem, I suppose the error message would be different, and it wouldn't just be thrown with "loop.last". I should add that the same template works perfectly with "loop.first", except that then of course it doesn't do what I want :-)

Birgit


_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to