I have a bit of a quandry I'm searching for anwsers on before I reinvent the wheel or do something silly -- like use the Expr module and make Sam feel more guilty then he does. ;)

I understand HTML::Template strength is that its a one pass parser which makes it highly efficient. That's why I want to try and use HTML::Template in my work. But one overriding need I have is to allow for a designer who doesn't know Perl (nor should they have) to work with the look and feel while a developer like myself works on logic and implementation. I couldn't find any reference to this topic in the archives.

Using a filter gives me the ability to create a more "user-friendly" (where user is non-Perl literate individual) template markup that I can translate into HTML::Template syntax. (Any tips, tricks or code samples other then what is in the docs would be appreciated. I figure this stuff out, I just hate reinventing the wheel.)

Here is the snag. I need to provide a designer that ability to apply any one or more of a number of filters that could occur post processing -- lowercase, strip tags, encode xml etc. Trying to predict and create every possible combination to pass into the template seems rather inefficent and an exercise in futility.

One way I thought this could be implemented would be to create a filter that not only translates the user-friendly template markup to HTML::Template markup, but interprets calls for filters to be applied (as attributes to the user-friendly tags) and places markers in the HTML:Template code. (i.e. <FILTER:lowercase>...Foo...</FILTER:lowercase>) Then, once the template has been merged with the data a postfilter scans over the output for the markers and applies the filters to the text accordingly.

HTML::Template doesn't natively support a post filter though. (Or did I miss something in the docs?) So what is the best way to implement this?

my $template = HTML::Template->new(filename => 'zap.tmpl',filter => $filter);

my $content = $template->output();

return &post_filter_processing($content);

I beleive this would reduce caching performance, correct? Is there a better way? Sublass HTML:Template and add in the postfiltr functionality? Is this something that may add in a latter release HTML::Template?

Any thoughts would be apprecaited.

<tim/>
--
Timothy Appnel
http://tima.mplode.com/

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to