I use TT2 (Template Toolkit) for creating dynamic web sites from SQL databases very quickly and easily. I like TT2 because I can retrieve a SELECT FROM...WHERE from the content database and then loop through the data, use a column as a flag to tell me how to process the data, and then output it to the HTML.

<!-- start of sidebar --> [% FOREACH sdbar = sidebar %] [% SWITCH sdbar.htag %] [% CASE "CC" %] [% sdbar.ctext %] [% CASE "CH" %] [% sdbar.htext %] [% CASE "/DIV" %] </div> [% CASE "DC" %] <div class ="[% sdbar.htext %]"> [% CASE "DI" %] <div id ="[% sdbar.htext %]"> [% CASE "P" %] <p> [% CASE "/P" %] </p> [% CASE "DIT" %] <div id="mkdoc-children" title='Sidebar menu for "[% g_company %]".'> [% CASE "LL" %] <li xml:lang="[% g_lang %]" lang="[% g_lang %]" class="lang-[% g_la +ng %]"> <a title="[% sdbar.ctext %]" href="[% g_sitename %]/[% sdbar.htext %]" hreflang="[% g_lang %]">[ +% sdbar.dtext %]</a> </li> [% CASE "H1" %] <[% sdbar.htag %]>[% sdbar.htext %]</[% sdbar.htag %]> [% sdbar.ctext %] [% CASE "H2" %] <[% sdbar.htag %]>[% sdbar.htext %]</[% sdbar.htag %]> [% sdbar.ctext %] [% CASE "UL" %] <ul> [% CASE "/UL" %] </ul> [% CASE "LI" %] <[% sdbar.htag %]>[% sdbar.ctext %]</[% sdbar.htag %]> [% CASE "@C" %] <!-- [% CASE %] An unexpected error has occured.<BR><B>[% sdbar.htag %]</B><BR> [% END %] [% END %] <!-- end of sidebar -->

The power of the template language makes for MVC like another poster mentioned, the seperation of content, data, and templates.

Richard

There are three types of people in this world, those that can count and those that cannot. Anon


In reply to Re: templates vs here docs by richardX
in thread templates vs here docs by grashoper

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.