in reply to HTML::Template : How to separate code and html with lesser maintenance issues
So no ifs are needed in your template (i try to put as less logic as possible in my templates as i can)my $tmpl = ""; my $item = "CONTINUE"; if ($item eq "SELECT") { $tmpl = "select.tmpl"; } elsif ($item eq "CONTINUE") { $tmpl = "continue.tmpl"; } elsif ($item eq "DENIED"){ $tmpl = "denied.tmpl"; } my $template = HTML::Template->new( filename => $tmpl );
# template.tmpl <TMPL_VAR NAME="function_xyz"> # Perl: my $tmpl = HTML::Template->new( filename => 'template.tmpl' ); my @all_params = $tmpl->param(); foreach (@all_params) { if ($_ =~ /^function_/i) { my ($a,$b) = split (/_/,$_,2); $tmpl->param($_ => $b() ); } } sub xyz { return "template value needed"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: HTML::Template : How to separate code and html with lesser maintenance issues
by blazar (Canon) on Nov 21, 2006 at 10:38 UTC | |
|
Re^2: HTML::Template : How to separate code and html with lesser maintenance issues
by tinita (Parson) on Nov 21, 2006 at 12:25 UTC | |
by jbrugger (Parson) on Nov 21, 2006 at 12:48 UTC |