[Templates] Auto-increment?

Josh Rosenbaum josh@infogears.com
Tue, 12 Sep 2006 16:39:44 -0600


Evan Carroll wrote:
> This might be accomplished with a continuation on a MACRO or the like.
> or using a global variable and passing it to functions.
> 
> I personally would just manually set the tab index, and include
> tabindex="$var" in the MACRO;
> 
> so the syntax would look something like this:
> 
> <input name="DoIt" [% tabindx(5) %]>
> 
> or 
> SET tab_cnt = 1;
> <input name="DoIt" [% tabindx(tab_cnt) %]">
[SNIP]

I think the problem with this is that the scalar variable is localized, and will never have it's value changed.

However going off the "list" method I mentioned before, you could do something like this:
[% tabidx = [87] %]
[% MACRO tabinc BLOCK %][% tabidx.0; tabidx.0 = tabidx.0 + 1; %][% END %]

[% tabinc %]<br>
[% tabinc %]<br>
[% tabinc %]<br>

I tested that and it appears to work fine. All the scalar methods I tested did not work, though.

-- Josh