[Templates] filtering includes

darren chamberlain dlc@users.sourceforge.net
Tue, 5 Nov 2002 08:40:10 -0500


* Rafiq Ismail (ADMIN) <rafiq@joshua.dreamthought.com> [2002-11-05 08:11]:
> On 5 Nov 2002, Simon Wilcox wrote:
> > On Tue, 2002-11-05 at 12:10, Rafiq Ismail (ADMIN) wrote:
> > To do the substitution I would use a FILTER on the assembled output.
> > This is what I'm currently writing to handle the munging of img
> > tags.
> 
> Thanks, muchly appreciated.
> 
> So, just for clarity:
> 
> I'll be using a ... FILTERS =>{ 'substitute' => [sub { s/$_[0]/$_[1]/g;},
> 1]} ... in my constructor, with:
> 
> [% FILTER substitute model.qr_left, model.qr_right %]
> [% INSERT 'my/file' %]
> [% END %]
> 
> should this do the trick?

In addition to all the above, I'd wrap the whole thing in a macro or
wrapper as well -- eventually you'll want to stop using the old method,
yes?

  # frob.tt
  [% MACRO FROB(file) %]
  [% FILTER substitute model.qr_left, model.qr_right %]
  [% INSERT $file %]
  [% END %]

  # Normal template
  [% PROCESS frob.tt %]

  [% FROB('my/file') %]
  [% FROB('your/file') %]
  [% FROB('their/file') %]

(darren)

-- 
Men are from earth. Women are from earth. Deal with it.