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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|