[Templates] auto filtering

Mark Fowler mark@twoshortplanks.com
Tue, 12 Nov 2002 16:21:03 +0000 (GMT)


On Tue, 12 Nov 2002, Andy Wardley wrote:

> You could write a custom stash which puts a wrapper around the 
> get() method, filtering all the output that it returns.

Putting it at the stash level seems to be a mistake to me...you often want 
to manipulate the data and do a lot of stuff and not have to worry about 
filtering it until the last matter.  You're essentially dealing with the 
data at too early a place in the parser.

Since we're talking about being lazy here, I'd probably implement it as an 
option to auto filter interpolated variables.  So in this example:

  This is a [% foo %] with very many $bar.

foo would not be filtered, but $bar would be.  This seems to give you the 
right degree of balance between convenience and flexibility.

Does this make sense?

Mark.

-- 
s''  Mark Fowler                                     London.pm   Bath.pm
     http://www.twoshortplanks.com/              mark@twoshortplanks.com
';use Term'Cap;$t=Tgetent Term'Cap{};print$t->Tputs(cl);for$w(split/  +/
){for(0..30){$|=print$t->Tgoto(cm,$_,$y)." $w";select$k,$k,$k,.03}$y+=2}