|
|
Choosing A Webhost: |
Re: Re: H::T future: msg#00053lang.perl.modules.html-template
On Wed, Dec 10, 2003 at 12:18:52PM +1100, Mathew Robertson wrote: >Is this implemented as a filter? In any case, I would be interested in having >a look at how you did this. Very much like the param version just posted here. Insert tags of the form: <tmpl_set name=x value=y> with _no_ quoting around the x and y (this is a quick-and-dirty hack); each one will provide a value for a top-level parameter. You can't do anything about values within loops with this. package HTML::Template::Set; use HTML::Template; use base qw(HTML::Template); sub new { my %set_params; my $set_filter = sub { my $text_ref=shift; my $match='<(?:\!--\s*)?tmpl_set\s*name=(.*?)\s*value=(.*?)\s*(?:--)?>'; my @taglist=$$text_ref =~ m/$match/gi; while (@taglist) { my ($t,$v)=(shift @taglist,shift @taglist); $set_params{$t}=$v; } $$text_ref =~ s/$match/<tmpl_if name=never><tmpl_var name=$1><\/tmpl_if>/gi; }; my $proto = shift; my $class = ref($proto) || $proto; my $self=HTML::Template->new(filter => $set_filter, @_); bless ($self, $class); $self->param(%set_params); return $self; } 1; ------------------------------------------------------- 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
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: enhancements to H::T, Mathew Robertson |
|---|---|
| Next by Date: | H::T in mod_perl (probably FAQs), Emanuele |
| Previous by Thread: | Re: Re: H::T future, Mathew Robertson |
| Next by Thread: | Re: Re: H::T future, Karen J. Cravens |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |