in reply to HTML::Seamstress - the Outsider
in thread RFC - Template::Empty

Both pipeline and callback are pull-style. XMLC and Seamstress are push-style.

"Pipeline" in my essay means that the code is in charge of control flow rather than the template. In a callback style, decisions about what do next are in the template. Seamstress is pipeline.

The issue I referred to with code being tied to presentation in a DOM approach is that you have to know the structure of the DOM. For example, filling in a variable in a specific paragraph or table requires you to say exactly which paragraph or table cell to fill. You have to write code like this:

$node->children()->[0]->text( $flavor_name );

If you use ID or CLASS attributes on the HTML tags instead, you can move them around without changing your DOM calls. I don't think we disagree, since your examples all use ID or CLASS attributes, not DOM location. You probably just have a different name for what I call DOM manipulation, like maybe XPATH.

HTML_Tree is not like Seamstress or XMLC. HTML_Tree is like Petal.

I don't see how. Petal embeds a programming language in XML files. HTML_Tree and Seamstress and XMLC all use ID and CLASS attributes to specify parts of an HTML file to replace or modify without embedding loops or conditionals in the template itself. (HTML_Tree can use XPATH-like code if you choose to, and I suspect the others can too, but that would be a bad idea for most situations.)

Replies are listed 'Best First'.
HTML::Seamstress - a push-style templating system
by metaperl (Curate) on Feb 26, 2008 at 17:17 UTC
    Pipeline" in my essay means that the code is in charge of control flow rather than the template. In a callback style, decisions about what do next are in the template. Seamstress is pipeline.
    Seamstress is push-style. Every other system on CPAN, whether callback or pipeline, is pull-style... oops! Template::Recall is push-style also. I have had little success in trying to email the author to chat
    Petal embeds a programming language in XML files.
    haha! told you fergal (grin).
    HTML_Tree and Seamstress and XMLC all use ID and CLASS attributes to specify parts of an HTML file to replace or modify without embedding loops or conditionals in the template itself.
    I see where you are coming from
    • they all only use Perl and HTML (no mini-language).
    • There is no embedding in the template.

    I have some comments on your article, having read it closely:

    HTML::Template is fairly rigid about insisting on a pipeline approach. It doesn't provide methods for calling back into Perl code during the HTML formatting stage; you have to do the work before running the template. The author of the module consider this a feature since it prevents developers from cheating on the separation of application code and presentation.
    You might mention that HTML::Template::Expr adds callback support for HTML::Template.
    There is a third approach, based on parsing an HTML document into a DOM tree and then manipulating the contents of the nodes. The only module using this approach is HTML_Tree.
    That is not true. Seamstress does that. In fact Seamstress is on CPAN and maintained. HTML_Tree cant claim either of these things.
    (said about HTML_Tree) This allows it to use genuine valid HTML documents as templates, something which none of these other modules can do.
    You mention Petal in your survey. It (and Seamstress) certainly guarantees this. HTML::Template and tt have support for changing the template delimeter to an HTML comment, which might help.
    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