Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Imagine a page with 20 variables. The templates look almost exactly the same for Petal and Seamstress but Seamstress also requires 40 almost identical lines of Perl to find the ids and replace them.
Actually, I believe your assessment is based on my slow, plodding examples which dont use the convenience methods in HTML::Element::Library. Please take a look at that library module, in particular the content_handler subroutine and then understand that the Seamstress code can be quite concise. In fact, even without looking at that, did you notice my second way of rewriting the example? I did not use the id tag from the HTML more than once in the Seamstree code. I repeat:
# look ma, concise code! for my $content (qw(name last_login)) { $tree->look_down('tal:content' => $content) ->replace_content($hash->{user}{$content}); }
This means that each ID tag has to appear twice, once in the template and once in your Perl, plenty of opportunity for typos.
I have the same thing in both places: an id tag. Petal has a data structure in one place and a mini-language to drive access to the data structure in the other. Typos happen. Test suites catch them. Both frameworks have things to do in Perl and HTML.
Lets say you decide that your template should display a field that was previously omitted. Now you have to change your template _and_ add 2 more lines of Perl to make sure it gets replaced.
And with Petal, you have to go retrieve the field again and make sure that the access of the field syncs up with TAL specifier. We both have to do work and again you overstate the number of code lines due to lack of familarity with convenience libraries.

And at some point, you are going to have to go into the HTML and do your mini-programming. I _never_ have to touch the HTML as long as the designer puts an id tag wherever dynamic functionality is needed.

At which point I'd have basically invented the main part of TAL. Mini-languages are bad but I'll take a small, tight mini-language any day over lines and lines of cookie cutter coding.
Perl is a powerful general purpose programming language offering numerous facilities for re-use: hashes, subs, modules, objects, normalized database access, etc. Writing cookie-cutter code in _any_ domain is un-necessary if you know Perl and have a background in software engineering. The codebase of Seamstress in the online website I just developed does not suffer from your proposed weakness.

Further, when the unrolling tasks becomes more difficult, such as moving around div elements or adding 2 or 3 attributes to an element based on complex business logic, I expect the mini-language to peter out or resort to PERL tags while my end-to-end Perl approach will continue to support me even at such higher levels of dynamic HTML munging.

At any rate, Petal and Seamstress and XML::LibXML all stress non-invasive HTML templating. And any of the 3 is hugely preferred over any other existing approaches for me.

And don't forget: Seamstress is not alone! It has a counterpart in the Java world named XMLC. And I must thank Chris Winters, the person who initially pointed this framework out to me.

Nice discussion. Thanks for your input!


In reply to Re^6: Survey of Surveys on HTML Templating systems by metaperl
in thread Survey of Surveys on HTML Templating systems by tphyahoo

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (6)
    As of 2014-07-30 02:59 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (229 votes), past polls