[Templates] auto filtering

Jonas Liljegren jonas@liljegren.org
12 Nov 2002 15:08:08 +0100


Andy Wardley <abw@andywardley.com> writes:

> David Dick wrote:
> > Encountering a personal need for some sort of auto filter option in tt,
> > so my html coder can put [% whatever %] and get the same results as if
> > they had been good and put [% whatever | html %].  Anyone else
> > interested in this sort of option?
> 
> If you want to filter each and every template in entirety, you can do 
> something like this with the PROCESS option:
> 
>   my $tt = Template->new({
>       PROCESS => 'wrapper',
>   });
> 
> wrapper:
>   [% PROCESS $template FILTER html %]

No. That would destroyt all the markup.

It should only filter all the GET things.

Everyting that comes from functions, methods, database values...

If you have succeded in separating presentation with data, the html
filter should be added to every singel GET.

Example:


<h1>[% title %]</h1>

<p>Date: [% date %]

<div class="entry">[% entry %]</div>

<hr>



Now. Can you think of any case there the GET should NOT be HTML
filtered?!?


In my lazy templateing, I often omit the html filtering just because I
don't expect any '&' och '<' inte the title or date or whatever.  But
they could be there and everything, EVERYTHING, should be filtered.

Then why not declare a default filter?

-- 
/ Jonas  -  http://jonas.liljegren.org/myself/en/index.html