Re: [htmltmpl] TMPL_XXX idea SCOPE
Brought to you by:
samtregar
From: Sam T. <sa...@tr...> - 2005-03-02 16:45:36
|
On Tue, 1 Mar 2005, Robert Ferney wrote: > I envision something like > <TMPL_SCOPE NAME="other"> > <div style="color:<TMPL_VAR color>;"><TMPL_VAR name="bar"></div> > </TMPL_SCOPE> > > this would be a slight variation on the TMPL_LOOP with the main > difference being that there is only one of them, rather than a list of > them.. ie.. it's going to get a HASH ref instead of a LIST ref that > contains HASH refs. > > I'm looking at the code now, I don't think this should be *too* > difficult. but any time you have to grok someone elses code it is > going to take longer than it would someone who is already familiar > with it. I think this could be done relatively easily in a sub-class using filter and an overridden param(). Here's how: - Your custom filter parses the SCOPEs and find VARs inside them. It alters their names to include the SCOPE name. For example, a var named "foo" inside a scope called "bar" might be "foo...bar". - Your custom param() looks for hash-refs and similarly modifies their names into "scope...var" format. - For extra credit, catch exceptions and fix the names so they don't expose the grotty internals to the end user. -sam |