Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: templates vs here docs

by richardX (Pilgrim)
on Dec 20, 2007 at 00:17 UTC ( [id://658022]=note: print w/replies, xml ) Need Help??


in reply to templates vs here docs

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://658022]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-25 08:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found