Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Thanks for the softball.
and thank you for taking a swing :)
Without manipulating the data in the perl layer, please provide one template that shows them in a bullet list and another template that shows them in a table with three columns with data oriented in columns with one item per cell.
I read your definition of Perl layer below. The first comment is that Perl layer is not a fine-grained term. It is a monolithic concept which does not accurately point out the (supposed) source of problems with push-style dynamic html generation. The second comment is that Perl is the practical extraction and report language. It excels at manipulating data. I therefore refuse to use a template system for manipulating data. Model actions belong in model, not anywhere else. And the model is best done in pure perl.

Your sample tt code mixes concerns. Data processing should be testable completely offline.. and completely free of any view. Mine is. Yours isn't.

On the column oriented version fill in   wherever there isn't a defined value.
uh... no. I will fill in space in my model code function reformat_data. Then delegate the conversion of space to   to the HTML renderer....
Be sure external whitespace is nice and consistent.
What is external whitespace?
For extra credit - make the template decide conditionally that if you have less than n items use the bullet list - otherwise use the table.
That's really just basic Perl:
my $model = Model->new; @$model < $n ? render_bullets($model) : render_table($model);
For extra extra credit - do this exercise - but do it in a text-only based email that will be sent to a user (ie - no html tags).
Well you didnt do it. I'm not sure how I would do that. Maybe an html2text tool?
To me the code layer would be your perl modules and your cgi script (or your mod_perl application). The example given is simplified and contrived - but represents real life situations.
It's a good example. But once you see my code, please point out the perrin-rhandom syndrome in the push-style approach or recant the criticism.
Update 2 s/specifying/manipulating the data/
Again a request I cannot comply with. I will never forget the time that Ovid tried to justify things like this, by calling it "presentation logic" and saying that a "presentation tool" like tt would be good for it. I disagreed with him then and with you now. No one should request data processing anywhere but a data processing giant (Perl).

Now, it has taken me probably 1 hour to write that code. I'm sure it took you less than 5 minutes. I'm a bit rusty in Perl, since I mainly convert Perl ETL scripts to Ab Initio data flow graphs these days. But I would not have been much faster. Push-style development is much slower. And I am grateful to have had a chance to shake the rust off myself :)

Code post follows.

I have beheld the tarball of 22.1 on ftp.gnu.org with my own eyes. How can you say that there is no God in the Church of Emacs? -- David Kastrup
[tag://long,live,html,seamstress,and,template,alloy,too]
Enforce strict model-view separation in template engines via HTML::Seamstress The car is in the cdr, not the cdr in the car

In reply to Re^2: object-oriented composition of model-view with HTML::Seamstress by metaperl
in thread RFC - Template::Empty by redhotpenguin

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 chanting in the Monastery: (10)
    As of 2014-09-22 19:32 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (198 votes), past polls