My favorite is either Template Toolkit or HTML::Template. Both keep the code and HTML seperate, which I think makes everything much easier to deal with as you keep the presentation of your content seperate from the logic of the program.

HTML::Template is useful if all you need to do is replace values in a template, perhaps with some simple conditional processing. It goes to the extreme of keeping code and HTML seperate.

For anything very complicated, I go with Template Toolkit as it allows the construction of fairly complicated templating systems and has plugins for various things. It does mix code and HTML a little and even has something of its own language. But I've found that once you start dealing with templates that can end up looking very different based on user input, that extra flexibility gained by having some code in the template ends up making things much easier to understand (though I think you should still keep most of the logic in the Perl program that is calling the template and avoid using callbacks). Template Toolkit does have a little bit steeper learning curve, but once you understand the basic syntax, it's pretty easy.


In reply to Re: Your Favorite XHTML Template System by Mr_Person
in thread Your Favorite XHTML Template System by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.