Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

HTML::Seamstress is not a templating engine?

by metaperl (Curate)
on Aug 03, 2009 at 12:45 UTC ( #785446=perlmeditation: print w/replies, xml ) Need Help??

In section 5, Terence Parr defines a template as:
A template is an output document with embedded actions that the engine evaluates when rendering the template.


Server-side includes can be considered templating.

Print statement

How about this program:
out.println("<html>"); out.println("<body>"); out.println("<h1>Servlet test</h1>"); String name = request.getParameter("name"); out.println("Hello, "+name+"."); out.println("</body>"); out.println("</html>");
is this a template?
output document
I dont see an output document... maybe the subroutine can be considered an output document.
The embedded actions?
I guess string concatenation.
The engine in this case is the Java programming language.

real templating

There's no question that HTML::Mason, etc are template engines


I'm not so sure that HTML::Seamstress has templates. Let's look at the definition again:
output document
an HTML file... so far so good.
The embedded actions?
There really are none. An XHTML compliant file doesnt necessarily have embedded actions.
The engine in this case is not-fixed. There is no fixed way of looking at an XHTML file that forces it to be dynamically produced in any particular way. Template engines have a fixed way of looking at embedded actions. Let's example a bit of SYNOPSIS code from the Petal distro:
<html xmlns:tal=""> <body tal:content="bar">Dummy_Content</body> </html>
Petal has one way of processing that body tag: it will do a replacement. Seamstress has no fixed protocol between Perl and HTML. It could do a replacement there. But it could also simulate the INCLUDE mechanism of another template system and locate a file named bar.html and inline it. Or it could locate a method named bar and call it. No fixed protocol.

Dynamic HTML production... without templating

Templating engines are designed to ease text production and may or may not have special support for HTML. HTML::Seamstress is designed solely for object-oriented HTML production. So there is some overlap between the functionality of templating systems and a dynamic HTML generation API, but they dont serve all the same purposes or have the same set of functional components.

Opinions encouraged

I am curious about whether you agree or disagree with my position and why.

Replies are listed 'Best First'.
Re: HTML::Seamstress is not a templating engine?
by pKai (Priest) on Aug 03, 2009 at 19:44 UTC

    Also in the same chapter Parr writes:

    Interestingly, by this definition of a template, XSL ... style sheets are not templates at all because style sheets specify a set of XSLT tree transformations whose emergent behavior is an XML or HTML document. XSL style sheets are programs like servlets, albeit declarative in nature rather than imperative.

    And I was never absolutely sure where the real dinstinction is drawn here.

    When your "traditional" templating system tends to become a Turing complete programming language, the distinction blurrs away anyway.

    I like in XSLT that it won't break the tree structure of the "template" I'm working in (XML, XHTML). So typically for my taste it's a better fit. Which might only be exactly that.. a matter of taste.

    The same might or might not apply to you and your HTML::Seamstress.

      The same might or might not apply to you and your HTML::Seamstress.
      Seamstress uses HTML::Tree, so well-formedness is guaranteed. it even does some auto-corrections. A colleague of mine was trying a browser hack where he tried to stick form tags inside a table and it kept rejecting his HTML.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://785446]
Approved by planetscape
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2021-04-20 06:26 GMT
Find Nodes?
    Voting Booth?

    No recent polls found