We seem to have established that the question isn't really "Dancer vs. my homebrew webapp framework", but rather "templated HTML vs. my homebrew HTML generator". So, then, what do templates buy you?

Simplicity, for one. I glance at the TT (Template Toolkit) template in your post and immediately understand what it is, what fields the form has, etc. Aside from being several times as long, I need to actually read your HTML generation code and think about what it says before I can figure out what it's going to create. To be honest, when I read your post and saw "I'm not impressed with this small HTML template and consider this huge mass of Perl to be a 'simple amount of code'", I initially suspected you were joking.

The biggest thing that using templated HTML instead of generated HTML buys you, though, is separation of concerns. Your Perl code just stuffs all the data into a hash (or whatever other data structure) and hands it off to the template engine, then the template engine uses the template to figure out how to display that. This lets you do things like provide a basic HTML version of some data, a fancy HTML version of that same data, an XML version to feed to other software, a JSON version to feed to yet other software, and a CSV version for exports, all with no changes to the Perl code. All you have to do is specify a different template to the same underlying data structure.

A nice side effect of this separation is that, if you don't want to get your hands dirty with HTML editing (and I can't blame you; I avoid the stuff as much as I can, too), you can pass it off to actual web designers and let them create hand-crafted, artisanal HTML with all the bells and whistles and latest design fads, then turn that into a template (usually a simple process, or, if you're lucky, you might find a designer willing to learn to create templates himself) and you're good to go. And when the next design fad hits, it's just a new template away. You can even keep the old template available and let users choose which version they want to see.


In reply to Re: To Dance or not to Dance with Dancer2? That is the question. by dsheroh
in thread To Dance or not to Dance with Dancer2? That is the question. by nysus

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.