The best reason to use any template language, in any system, is in the readability and functionality a template language brings.
Yes, your function is somewhat readable. Very much so. The problem is, it doesn't scale. For any HTML entity, any visual reference, it can affect another entity or reference. If I want to apply css, js and what not, I don't have a single document that contains everything in a single view. What's worse is, to find any particular piece, I have to go backwards and figure out what calls what. In a template, things are intended to be more flat - like a program w/ no user defined functions. Everything reads top down, loops get hit, variables get assigned an life goes on.
The intended target is also valuable. I can hand a template to a designer and state, "This is the syntax, be it simple like Html Tmplate, or Mason, tweak it so it's a horizontal scrolling page instead of vertical." Less things to break. The separation is nice because it is a controlled separation. Sure you can get around it, but it's fairly obvious when it gets complex. The reverse is true too. I can take an HTML file, and replace a mockup of a few rows into a loop quite easily, pass it back and ensure life is good.
-
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.
|