in reply to Re: The scope of templates
in thread I need a title - sucka! :-)

We probably should discuss this out. It is important.

While I agree, that a templating system has many advantages over a simple here doc (HD), it is also true that a HD with interpolation is already a simple templating system.

Furthermore if you have a close look at all the templating modules at CPAN, you will find there some enabling "real perl processing", thus inlining perl into templates. Wuuuh... Bad idea. So instead of inlining text into Perl (HD), you inline a template into perl only to find, that you need more expressive power so you inline Perl into the text you inlined into Perl. Very bad.

Lets assume our standard case. For every nontrivial HTML document (heavy-duty dynamics), you have not only to interpolate variables, but also do some more processing which is done in some subroutines/submodules. So what do you do? You use Perl to generate the document and use HDs for the simple things/static parts.

Now to sum up what impression I really get: many templating system advocates are blind because of the greater expressional power of the templating system (compared to HD), so they try to apply templating to every document generation.

This is wrong IMHO. Speaking of expressional power you have

E(Perl) >> E(Template) >> E(HD)
Don't try to warp the Perl/Template ordering. Just believe me. Been there - done that.

Bye
 PetaMem
    All Perl:   MT, NLP, NLU

Replies are listed 'Best First'.
Re: Re: Re: The scope of templates
by BUU (Prior) on Nov 22, 2003 at 16:27 UTC
    Thats wonderful. And what happens when somebody wants to change the font color to red? You get your text editor, open the perl script, find your heredoc (wherever it is) and then change the font color. Oh wait, he prefers the font color to be blue instead. No.. green. And so on and so forth. Or other minor graphical changes that should really be the providence of the web *designer* as opposed to the web *programmer*. Templates of course avoid both of these issues. As for inlining perl in to text, <tmpl_var foo> is hardly what *I* would call perl code. And what about caching? You can't cache individual here docs.. you can templates. Not to mention templates can also help impose a more logical structure upon your program.
      If you have choosen to provide far reaching look&feel configuration in your more-than-average dynamic pages (which you most probably have), you solve these kind of things with CSS.

      BUT if you really need to have the font color changed quick & dirty, you will provide a button/selection box somewhere filling a var $font_color and in your (interpolating) here doc there will be:

      <font color="$font_color">

      Bye
       PetaMem
          All Perl:   MT, NLP, NLU