On Sat, 15 Sep 2001, Raymond B. wrote:

> For a test a bunch of us changed our tmpl parser to relect these shortened
> versions:

No need to change the parser - just use a filter!

> <tmpl_var name="foo">                 <~foo~>
> <tmpl_loop name="bar">                        <_loop name="bar"></_loop>
> <tmpl_if name="baz">                  <_if name="baz">
> <tmpl_include name="foo/bar.baz">     <_include name="foo/bar.baz">

Wow, I must admit - that's the strangest set I've seen yet!  What is that
underscore doing there?  Regarless, it's a very simple filter:

  $t = HTML::Template->new(filename => 'foo.tmpl',
         filter => sub { $$_[0] =~ s/<~(.*?)~>/<tmpl_var name="$1">/g;
                         $$_[0] =~ s/<_(.*?)>/<tmpl_$1>/g; });

> Now don't get me wrong, I love HTML::Template and it's already saved many
> hours (and probably my sanity). In fact the seperation philosophy means I
> can use it for more than just HTML. The purpose of this is more to see your
> reasoning behind choosing as you did.

The reasoning was simple - I thought that the syntax should be as close to
normal HTML as possible.  I felt this would lower the learning curve for
designers with no programming experience.  I don't believe for a moment
that I've discovered the ONE TRUE template syntax, but I generally find it
serviceable.

-sam



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to