bart has asked for the wisdom of the Perl Monks concerning the following question:
So, this is a bit of a contest for templating systems, I am curious how you would implement one particular example problem, in your favourite templating system. The example problem is this: starting with a Perl array, it should produce the following output:
// BEGIN // END
// BEGIN switch(x) { case foo: // code for foo break; case bar: // code for bar break; case baz: // code for baz } // END
I'd like to point out one particularity, which often appears to be a weak spot. Note that there is no "break;" line after the last item in the list. The idea is that some particular text should be inserted between items in a loop, but not after the last item. It should act like the join string in join. As another example, it should be possible to expand a Perl array ("foo", "bar", "baz") into the text
Thus, with commas between the items, but not at the end.(foo, bar, baz)
Again: at this point, I'm only interested in the templates themselves, and not yet in the Perl code to drive it.
To show what I am after, it could be something like the following, fictional example:
// BEGIN <%IF @LIST%> switch(x) { <%FOREACH @LIST AS ITEM%> case $ITEM: // code for $ITEM <%CONTINUE%> break; <%/FOREACH%> } <%/IF%> // END
So, if you know of a templating system that can do something like this: great! If you know of something better still... even better! :)
|
|---|