Lance A. Brown wrote:
Argh. I can't remember where, but I ran across a Website package using HTML::Template that had this feature.
Aha! Found it!
Yapcom, the CGI::App-based application to handle registration and workshops for YAP conferences!
Here is the relevant piece of code. Personally, I think this is a VERY tasty hack. It lets page designers plug parameters back into the templating system for use elsewhere. Very cool.
sub _server_page { my $self = shift; my ($page) = @_; my $q = $self->query;
# we allow tags like this in our templates that will define values
# to be set as parameters
# <TMPL_VALUE NAME="name" VALUE="value">
my %h;
my $filter = sub {
my $text_ref = shift;
while ($$text_ref =~ s/<\s*TMPL_VALUE\s+NAME="([^"]*)"\s+VALUE="([^"]*)"\s*>//) {
$h{$1} = $2;
}
};
my $t = $self->load_tmpl( "$page.tmpl", die_on_bad_params => 0, filter => $filter, associate => $q, path => $templates_dir, );
$t->param(%h); $t->param(VERSION => $YAPC::Organizer::VERSION);
return $t; }
--[Lance]
The templates in the package have <TMPL_VALUE name="foo" value="bar"> tags and used a filter function to extract them from the templates and insert them into the template params. It was a very neat hack.
--[Lance]
-- Carolina Spirit Quest: http://www.carolinaspiritquest.org/ Celebrate The Circle: http://www.angelfire.com/nc/celebratethecircle/ My LiveJournal: http://www.livejournal.com/users/labrown/
------------------------------------------------------- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click _______________________________________________ Html-template-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/html-template-users