[htmltmpl] get value from template?
Brought to you by:
samtregar
From: Bill N. <bn...@co...> - 2004-11-04 04:31:39
|
I'm looking for suggestions on how to get a value from my template that can be used in my Perl code. I'd rather not switch to another template module that would provide this since HTML::Template has otherwise met my needs. The details... In my template, I'd like to have something like: <TMPL_VAR NAME="QUERY" VALUE="SELECT col1, col2 FROM table"> and then do something like this in my Perl code: my $template = HTML::Template->new(filename => 'test.tmpl'); my $value = $template->param('QUERY'); and have $value = "SELECT col1, col2 FROM table" My three thoughts are: 1. use a filter, but I don't know how to get $template instead of the filter subroutine so I can call $template->param to set the value. The only thing passed to the filter subroutine is the text of the file and not $self? 2. extend HTML::Template to handle this via the existing TMPL_VAR or add a new tag TMPL_DEFINE 3. Use HTML::Template::Expr, but my experience is that ::Expr is slow and I don't need all the other features it would provide. Comments on the above options or other thoughts on how to do this? Thanks, Bill |