in reply to HTML::Template::Compiled - TMPL_EACH

I'm no HTML::Template expert, but your code is weird. Here is an example adapted from
http://search.cpan.org/~tinita/HTML-Template-Compiled-0.92_001/lib/HTML/Template/Compiled/Reference.pod#LOOP,_WHILE,_EACH
http://search.cpan.org/src/TINITA/HTML-Template-Compiled-0.92_001/t/21_while.t
#!/usr/bin/perl -- use strict; use warnings; use HTML::Template::Compiled; { my $htc = HTML::Template::Compiled->new( scalarref => \'<%each foo%>key <%= __key__ %>=<%= __value__ %> <%/each%>', debug => 0, loop_context_vars => 1, ); $htc->param(foo => { a => 1, b => 2, c => 3 }); my $out = $htc->output; print $out,$/; } { my $htc = HTML::Template::Compiled->new( scalarref => \'<TMPL_EACH foo>key <TMPL_VAR __key__ >=<TMPL_VA +R __value__> </TMPL_EACH>', debug => 0, loop_context_vars => 1, ); $htc->param(foo => { a => 1, b => 2, c => 3 }); my $out = $htc->output; print $out,$/; } __END__ key c=3 key a=1 key b=2 key c=3 key a=1 key b=2

Replies are listed 'Best First'.
Re^2: HTML::Template::Compiled - TMPL_EACH
by moritz (Cardinal) on Sep 05, 2008 at 07:08 UTC
    Here's the template with more traditional markup:
    <TMPL_EACH res> <TMPL_VAR __key__ > => <TMPL_VAR __value__ > </TMPL_EACH>