Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Petal is pull-style... like TT/mason - Seamstress is push-style

by metaperl (Curate)
on Feb 25, 2008 at 14:55 UTC ( #670010=note: print w/ replies, xml ) Need Help??


in reply to Re: RFC - Template::Empty
in thread RFC - Template::Empty

This reminds me somewhat of Petal,
Actually not really, what the OP wants is much closer to my own HTML::Seamstress. Petal embeds a mini-language within HTML... Seamstress is pure Perl and pure HTML and nothing else.

Seamstress takes its inspiration from XMLC and I am very grateful to lachoy for mentioning it. Petal takes its inspiration from TAL.

To understand the difference between push-style templating (Seamstress) and pull-style templating (tt/mason/petal/html::template, etc) you should read Terence Parr's paper on the subject.

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://html,templating]
Enforce strict model-view separation in template engines via HTML::Seamstress The car is in the cdr, not the cdr in the car


Comment on Petal is pull-style... like TT/mason - Seamstress is push-style
Download Code
Re: Petal is pull-style... like TT/mason - Seamstress is push-style
by metaperl (Curate) on Feb 25, 2008 at 15:01 UTC
      Actually, your synopsis is good.
      I hate it when people does this; make me think. I think too much already. I'm not good at that.

      *sigh*
      How many times have I discovered that I've cut corners with TT, in the rush to implement / fix some borken functionality, brought more logic into the templates than I meant. It always sneaks in, because it's possible and convenient.

      I've read your synopsis, quickstart and what has been written here so far today, and I will give your HTML::Seamstress a spin the next week.

        Actually, your synopsis is good.
        I tend to think that people want to see code in a synopsis not a long-winded discussion. I moved that discussion way down and put some code samples in the synopsis for the 5.0a version I just uploaded
        How many times have I discovered that I've cut corners with TT, in the rush to implement / fix some borken functionality, brought more logic into the templates than I meant. It always sneaks in, because it's possible and convenient.
        hehe. I can imagine. And then the spaghetti gets deeper and deeper. i've had mason code like that. I simply cant think in terms of tt/mason anymore.
        I've read your synopsis, quickstart and what has been written here so far today, and I will give your HTML::Seamstress a spin the next week.
        I'm glad to hear that. There is a mailing list on sourceforge. I'm pretty response to messages. Overall, the whole Seamstress project needs thorough documenting. That's one thing about tt - the documentation is simply staggering.

        If Seamstress trips you up somewhere or is not as approachable as you would like, just hit me up here or on the mailing list and will clean things up.

        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://seamstress,templating]
        Enforce strict model-view separation in template engines via HTML::Seamstress The car is in the cdr, not the cdr in the car
Re: Petal is pull-style... like TT/mason - Seamstress is push-style
by Rhandom (Curate) on Feb 25, 2008 at 17:30 UTC
    ++

    Thanks for the link to the paper. I found it interesting. I also found it somewhat biased and amusing.

    I found it amusing because section 7.1 is labeled "Pull Strategy Violates Separation" - but he never treats the topic of whether "Push Strategy Violates separation."

    There are also statements such as "Strictly speaking the URL structure of the site belongs to the controller." This is nice in theory and is true in ideal situations. After 10 years of work in non-ideal situations I've found that it "strictly" isn't true. Sometimes templates contain links that take you in and out of the controller loop.

    The true bias is revealed when the last section of the paper is used to present his "new" templating system which does clear up some fuzzy boundaries - but doesn't provide anything truly remarkable over existing systems.

    Formal papers are nice in an academic sense, but that doesn't mean his experience has any direct bearing on the experience of others. He is welcome to argue his point, but in the end - all of the various models have managed to get the job done for people who have used them. Existing solutions are certainly good enough for all practical purposes.

    my @a=qw(random brilliant braindead); print $a[rand(@a)];
      Thanks for the link to the paper. I found it interesting. I also found it somewhat biased and amusing.
      I am grateful for the part just before Section 7.1 where he lists the 5 things that determine whether a template system is push-style or pull-style. I think you would agree that only Seamstress is push-style. Everything else on CPAN (including Petal) and HTML_Tree (not on CPAN) is pull-style.
      I found it amusing because section 7.1 is labeled "Pull Strategy Violates Separation" - but he never treats the topic of whether "Push Strategy Violates separation."
      I dont think it can. Can you provide an example of where it does? You only have meld3, Seamstress and XMLC and StringTemplate to pick on, because those the only push-style templating systems out there.
      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://push-style,html,templating]
      Enforce strict model-view separation in template engines via HTML::Seamstress The car is in the cdr, not the cdr in the car
        I still don't think your getting it. All "push" style has done is moved the "pull" into your perl layer. Seamstress requires too much knowledge about the template. TT is closest to give true separation because you can give it unblessed, raw, unformatted data. Anything that is not passed as unblessed, raw unformatted data has violated the separation - but that doesn't make it bad - it just makes it not academic.

        I don't think at this point that you will ever concede. I am somewhat saddened (but not that much) that you fail to see that Seamstress (and most likely all "push" systems) violate the separation of model and presentation in the exact opposite direction of "pull" systems.

        Well - I really must get back to work and my non-academic template implementations.

        Update - I think the problem here is when we are using the term "view." For me, the view is very nearly tied directly to the html/xml/text template with the TT or Template::Alloy object swapping in data that was prepared by the model and handed to the view by the controller. Your implementations of the view seem to include sections of Perl code that know what the template needs - and even more it knows what the template looks like, and then requests data from the model in the formats that the template needs - depending upon the model to get it into shape. This is where the argument comes in. TT models don't need to have Perl code as part of the "view" layer. Seamstress requires it. In the end we are arguing over borders which really is an inconsequential debate. Both models work equally well in the eyes of the end user (who never sees the code that generated the page). Both camps will be forever wrong in each others eyes. True separation is a decoy issue at best.

        my @a=qw(random brilliant braindead); print $a[rand(@a)];

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2014-09-03 05:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (35 votes), past polls