In my template,

[% FOR name IN name_list %]
[%- n = name.0 | lower %]
[%- IF category2article.$n %]
[% cats = category2article.$n -%]
/* [% n %] */
article_t cat_[% loop.count - 1 %][] = {
[%- cats.join (", ") -%], -1};
[%- END %]
[%- END %]

In the usual case, this produces

/* event */
article_t cat_748[] = {419, 1346, -1};

But when "name_list" contains the word "first",

/* first */
article_t cat_775[] = {HASH(0x2862d2d0), -1};

This seems to be some kind of mismatch between the template toolkit's
"first" keyword and the action of the variable $n. I am not sure if
this is the expected behaviour, but if it is, how should I have
phrased category2article.$n to avoid this?

At the moment I have just written a trap for it:

[% FOR name IN name_list %]
[%- n = name.0 | lower %]
[%- IF n != 'first' -%]
[%- IF category2article.$n %]
[% cats = category2article.$n -%]
/* [% n %] */
article_t cat_[% loop.count - 1 %][] = {
[%- cats.join (", ") -%], -1};
[%- END %]
[%- END # first trap -%]
[%- END %]

This works because I didn't need "first" as a keyword, but it's a bit
worrying that I have to do this and I suspect a bug.

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

Reply via email to