Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:
My colleague was very happy, and I then I showed her the template. "It uses a very simple template language..." I said, and saw the look on her face. She does not want to learn another template language.
So, here's the thing. In HTML::Template you do it one of two different ways. You either have code like this:
<tmpl_loop name="chart"> <tr> <td><tmpl_var name="chartposition"></td> <td><tmpl_var name="artist"></td> <td><tmpl_var name="song"></td> </tr> </tmpl_loop>
or you have code like this:
<!--tmpl_loop name="chart" --> <tr> <td><!-- tmpl_var name="chartposition" --></td> <td><!-- tmpl_var name="artist" --></td> <td><!-- tmpl_var name="song" --></td> </tr> <!--/tmpl_loop -->
but in neither case do you have actual working HTML. It's not valid in the first case, and the second case, while valid, doesn't render anything in the browser.
What my friend the busy web-developer would certainly prefer is if she could code up a web page like this:
<tr (repeat this row for each song please)> <td>number</td> <td>band name</td> <td>song name</td> </tr>
But obviously, that isn't valid HTML exactly either. So, I had what's either a brainwave or it's not, but everyone in these days of HTML 4 is already adding arbitrary markers to their HTML anyway. The classes (or IDs).
My friend will have to add a class here or there anyway, just to get the CSS right, and it really doesn't much matter what they're called.
So why can't we have a version of HTML::Template which works something like this?
<tr class="tmpl-loop-chart"> <td class="tmpl-var-chartposition">1</td> <td class="tmpl-var-bandname">OUTKAST</td> <td class="tmpl-var-songname">Roses</td> </tr>
That is, one where the developer could make up a template with any old content in it they wanted, and the module would parse the HTML and figure out that the loop ended with the next (balanced) </tr> tag, the TDs close with the next (balanced) </td> tag and so on, and replace the content of that tag with the data, rather than the artificial template-language tag which the developer has to learn.
What do fellow monks think?
($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
=~y~b-v~a-z~s; print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Thinking Aloud About HTML::Template
by adrianh (Chancellor) on Jul 31, 2004 at 13:39 UTC | |
|
Re: Thinking Aloud About HTML::Template
by Joost (Canon) on Jul 31, 2004 at 12:21 UTC | |
|
Re: Thinking Aloud About HTML::Template
by dws (Chancellor) on Jul 31, 2004 at 17:16 UTC | |
by mojotoad (Monsignor) on Aug 01, 2004 at 05:45 UTC | |
by dws (Chancellor) on Aug 04, 2004 at 01:20 UTC | |
|
Re: Thinking Aloud About HTML::Template
by bradcathey (Prior) on Aug 01, 2004 at 10:19 UTC | |
by Cody Pendant (Prior) on Aug 02, 2004 at 01:23 UTC | |
by grantm (Parson) on Aug 02, 2004 at 02:00 UTC | |
by Cody Pendant (Prior) on Aug 02, 2004 at 02:05 UTC | |
by grantm (Parson) on Aug 02, 2004 at 08:12 UTC |