HTML::Template::Pro: do something on second run of a loop

219 Views Asked by At

I am using HTML::Template::Pro in my perl application. I am displaying HTML elements in a loop and I want to show something after the second element of the loop. I added the loop_context_vars in my HTML::Template::Pro initialization, getting access to variables inside the loop (like __counter__).

Now I am looking for a way to check for a specific iteration of this loop to insert my HTML element.

<TMPL_IF __counter__ == 2>
   My new HTML element.
</TMPL_IF>

How can I access the __counter__ variable inside conditional statements in HTML::Template::Pro?

1

There are 1 best solutions below

0
On

In HTML::Template::Pro, you can use expressions like in HTML::Template::Expr

<TMPL_IF EXPR="__counter__ == 2" >
    My new HTML element.
</TMPL_IF>