
Originally Posted by
HarryF
No it doesn't hurt but I think when a particular wheel gets re-invented as many times as the template engine, it's interesting to ask why. More to the point, while building the list, I took a quick look at the examples and off the top of my head, at least 70% are "Smarty style" in that they have some kind of imperative syntax. Another 20%ish use HTML comments. In other words people are coming up with the same solution to the problem. Also the word "simple" appears with great frequency...
...snip...
8. Reduces the effort required build the templates.
First, #8 is covered under Simplicity. If the template engine makes something simple, it's also reducing the effort. If it's difficult to do something, even if the syntax is simple, the template is not simple. At least, that's my take, and how I interpret what I wrote, heh.
In response to your first paragraph, you make an interesting statement regarding how template languages look. Some using an imperative syntax, and some using HTML comments.
However, I believe both approaches are wrong.
A better way would be something like this:
Code:
<!-- IF isFormError -->
<dl>
<!-- LOOP ON FormErrors FOR EACH Error -->
<dt>{Error.Name}</dt>
<dd>{Error.Description}</dd>
<!-- END LOOP -->
</dl>
<!-- END IF -->
It mixes the two together. It passes the Dreamweaver test, it's simple. I haven't tested it, but it should validate. Assuming the template engine would compile this down to PHP (that sounds funny, compiling 'down' to PHP), it's cacheable. As far as being self-inspecting, secure, and flexible, well that's more an engine implementation.
However, some potential problems arrise:
Code:
<!-- IF isFormError -->
<dl>
<!-- LOOP ON FormErrors FOR EACH Error -->
<!-- ALTERNATE color BETWEEN 'red' AND 'blue' -->
<dt style="color: {color}">{Error.Name}</dt>
<dd>{Error.Description}</dd>
<!-- END LOOP -->
</dl>
<!-- END IF -->
Okay, pretty straight forward, and something that is easily parsed and compiled. Howver, you run into a problem with the use of color: {color}.
Simply put, it fails the Dreamweaver test.
Hrm.. got me thinking though.
Bookmarks