OK this is off the cuff and the title may be a little more contentious than what I really want to say.

When I see some people using or asking about templating systems and then as the conversation continues they don't seem to know why they are using them. That suprises me since I've always tried to follow a simple-is-best philosophy.

As I see it, from the perspective of using two packages and writing my own years ago, that templates have just a few specific uses.

The number one true use for templates is the one I hardly ever see people using anymore. Customisation is the real benefit of templates. My first system consisted of a single massive "directory handler" style CGI (later mod_perl) script that loaded various templates based on input and logged in user. The main template set had within it entire sections that were erased because the user had no permissions to use the tools they expressed. Better still, I could log in as a test user and work with an entire second set of templates and verify new features before anyone ever saw them or test template modifications without disturbing trained users.

The second big benefit that seems to be more popular these days is separation of display and action. Content vs. Code. This is usually only a real gain if there are a number of people working on a project or if the web design will predate the code design. Often, for the smaller systems I've seen discussed, being worked on by a single perl programmer, it would seem to be a useless detraction and dsitraction from a project. I see it as using Velcro to hold a car together. =)

The big gain that a lot of people see in templates that I don't particularly see is expression conciseness. They seem to look at it as turning HTML/CGI inside out. Rather than having a CGI with lots of prints delineated out special, they tend to write out the HTML and delineate the CGI code special. This is merely a comfort issue so I won't address it as positive or negative. The same work generally gets done though the price of doing it this way is often at complicating the webserver unnecessarily. Of course, if you already had to throw mod_perl or it's like at other problems, then you've paid the price already so o nuts. =)

Here are my two real questions: One, direct, are there other reasons you use templates that I missed or gains that I didn't state? Two, rhetorical, if you are about to use one template system or another do you know why?

--
$you = new YOU;
honk() if $you->love(perl)


In reply to Why use Templates at all? by extremely

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.