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.
SSI
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.
- Engine?
- The engine in this case is the Java programming language.
real templating
There's no question that
HTML::Mason, etc are template engines
Seamstress?
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.
- Engine?
- 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="http://purl.org/petal/1.0/">
<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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.