|With the loop_context_vars switch in HTML::Template you can make some useful macros. I found myself needing things like this all too often:
So I made a macro that handles this inside the template by adding a <TMPL_NUM foo> directive. Does anyone else have useful HTML::Template tricks up their sleeves?
foos => \@foo,
num_foos => scalar @foo,
bars => \@bar,
num_bars => scalar @bar,
By the way, I'm well aware that this is a great example of the serious limits of templating using HTML::Template's philosophy. This is some ugly template-ese under the hood. This is why I will probably switch over to Template::Toolkit in the not-so-distant future (at least for projects where I'm the one writing the template).