in reply to RFC - Template::Empty

This reminds me somewhat of Petal, in which you also have an "empty/sample template". Petal stores all the directives (like, which parts to repeat) in HTML attributes - I'm not sure how your template would know which parts to repeat (<tr> for table rows, <li> for list items etc.)...

Replies are listed 'Best First'.
Petal is pull-style... like TT/mason - Seamstress is push-style
by metaperl (Curate) on Feb 25, 2008 at 14:55 UTC
    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
      ++

      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
        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.

Re^2: RFC - Template::Empty
by fergal (Chaplain) on Feb 25, 2008 at 12:22 UTC
    Seconded. If you want to avoid programming in your HTML files and you want HTML that can be previewed and editted in HTML tools then Petal is there already.
      fergal sayeth:
      If you want to avoid programming in your HTML files and you want HTML that can be previewed and editted in HTML tools then Petal is there already.

      Your second point I agree with: Petal does maintain HTML that can be previewed and edited in HTML tools.

      But I disagree with your first point. I think Petal allows for programming in HTML. Sure the syntax of the programming language looks a bit different, but it's still programming in my book. And in a previous post you literally said: "petal's loops" --- now since you said that Petal had loops and since loops are a programming construct, you can program in petal...

      begin round two of fergal versus princepawn :) -- round one took place here

      Let's compare HTML::Seamstress, Template and Petal briefly:

      condition

      petal

      <span tal:condition="true:user/is_authenticated"> Yo, authenticated! </span>

      tt

      [% IF user.is_authenticated %] Yo, authenticated! [% END %]

      seamstress

      <div class="auth_dialog"> <span sid="authed"> Yo, authenticated! </span> <span sid="not_authed"> NOT authed </span> </div>
      use html::auth_dialog; my $tree = html::auth_dialog->new; $tree->highlander (auth_dialog => [ authed => sub { $_[0]->authenticated } not_authed => sub { 1 } ], $model ); print $tree->as_HTML;

      loop

      petal

      <tag tal:repeat="element_name EXPRESSION"> blah blah blah </tag>

      tt

      [% FOREACH s IN EXPRESSION %] * [% s %] [% END %]

      seamstress

      There are a number of looping methods abstracted into HTML::Element::Library for use with Seamstress in a disciplined object-oriented fashion...
      <div class="elemid"> blah blah blah </div>
      my $li = $tree->look_down(class => 'elemid'); my @items = qw(bread butter vodka); $tree->iter($li => @items);
      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,seamstress]
      Enforce strict model-view separation in template engines via HTML::Seamstress The car is in the cdr, not the cdr in the car

        Depends what you mean by "programming". You need more than conditionals and iteration of preexisting lists to be able to do general programming. Petal does not give you a turing complete language or anything like it. It simply gives you a way to render a perl data structure in HTML, adding the ability to render lists as repeated HTML and to conditionally drop certain sections of the template.

        That is not programming. For example, the rendering is guaranteed to terminate and while it is possible to set variable and keep state, this is rarely done - the only time I'd ever do it would be to make a short way of referring data at the end of a very long path expression.

        I guess it comes down to taste, I really like Petal's style of doing things.