I thought I'd drop a note on templating systems, since we seem to be having a
general discussion on it.  I wrote the Text::TagTemplate module (on CPAN these
days, even!) and though I'm not going to actively suggest anyone using it (it
lacks good looping and conditional constructs, for one thing), it does two
or three things that I really like ('cause I wrote them) and I'd like to see in
some of the other templating packages.

The first is easy template-coder-controlled HTML-escaping of interpolated
values, so I (the Perl programmer) can just throw unescaped form data back into
the template, and the templater-coder can do:

<INPUT TYPE="TEXT" NAME="first_name" VALUE="<#FIRST_NAME HTMLESC>">

to use it safely in forms (or just in HTML body text sections).

The second is easy template-coder-controlled URL-escaping of interpolated
values, so I can just throw form data back into the template, and the
template-coder can do:

<A HREF="/somehandler?email=<#EMAIL URLESC>">

to use it safely in links.

The third is easy template-coder-controlled -- are you detecting a pattern
here? -- conversion of template data to SELECTED or CHECKED, so they can do
this:

<INPUT TYPE="CHECKBOX" NAME="option_1" <#OPTION_1 CHECKEDIF="on"> >

or this:

<SELECT NAME="country">
<OPTION VALUE="uk" <#COUNTRY SELECTEDIF="uk"> > The Mother Country
<OPTION VALUE="us" <#COUNTRY SELECTEDIF="us"> > Some Other Country
</SELECT>

That last saves me an *enormous* amount of time either coding the same thing
every time I want to save state in a pulldown menu, or generating the whole
HTML code for the menu in my Perl code.

I've seen features one & two in some packages, in HTML::Template maybe, but I
haven't seen the third one anywhere at all.  Maybe I'm missing where someone
has already done it.

-- 
Jacob Davies
Lead UNIX Engineer
SF Interactive
[EMAIL PROTECTED]

Reply via email to