•Re: Re: Re: Re: HTML::Template - what's the rule of thumb?
by merlyn (Sage) on Dec 20, 2003 at 16:01 UTC
|
Still I think in the long run, templating systems are a dead branch of the evolutionary tree: they are neither pure programs, nor pure mark-up but a hybrid of the two, which IMHO combine the bad things of both for little benefit.
I'll disagree, on two levels.
One, in order to get a file that is "pure markup", you have to have some logic to generate that file. Parts of that logic will have static text, and parts must have enough dynamic logic (decision/iteration/subroutines) to be turing complete. That's actually a perfect place for a templating system!
Two, if you follow the MVC paradigm, your View usually ends up having to adapt to display the Model being tossed at it by the Controller. A good templating system has at least enough stuff to do that, although it doesn't need (or want) to have enough stuff to be the Controller itself. I think the failure of some templating systems is their attempt to be used as Model or Controller code.
An example of a failure of "pure markup" is XSLT. You end up twisting yourself around corners just to write programs in what tries to be a pure mark-up language. Feh.
If you think templating systems are a dead-end, you should probably describe what you would replace them with. It's also possible that you have a narrow application domain that you're specifically addressing. It'd be nice for us to know your scope of statement.
| [reply] |
|
I run an intranet site which gets data on marine claims out of a database. The various perl scripts generate XML output which are then transformed by XSLT into pure HTML (and CSS provides for the standard look as per our corporation's "look and feel" guidelines).I run one large XSLT file for all the webpages and if something global needs to be changed I do it in one place and everything follows.Recently a customer requested that certain columns on the webpages needed to be summed. This only was a small change in the XSLT and nothing had to be changed in the scripts. Now you probably are going to say that you could just as easily have amended the template (but probably many different templates needed to be adapted) and you are probably right. But XSLT has a lot more possibilities than any templating system. In that, it is less (or even not at all) a mark-up language (certainly not a pure mark-up language) than a programming language in its own right. Yes it means you have to learn an extra language, but I happen to like it and it provides nice buzzwords to pacify the PHB!
CountZero "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
| [reply] |
|
But XSLT has a lot more possibilities than any templating system.
You had me up to here. Then I lost you, because you never justify it,
and this is the point we differ on.
A "templating system" like Template Toolkit has all of Perl to escape
to, without shifting gears. To extend XSLT, you have to code in some
non-XSLT language. This implies the opposite of your statement.
What axis of interest are you looking at to say what you said?
| [reply] |
|
|
I think you're missing the point of a templating system. It has nothing to do with making sure that your display logic doesn't have any programming stuff in it. In fact, I am switching from HTML::Template to Template Toolkit precisely because it has better programming stuff in it.
Within MVC (which it seems you do use - good for you!), you will have three programming layers, hopefully separated by rather strict APIs. Each of the layers, most likely, will have a ton of programming in them, and that's ok. Very often, one cannot convert a data structure into something to be displayed without it.
The notion that templating systems should be as dumb is possible is a mis-meme, promulgated by the facts that
- HTML::Template is the most popular templating system in Perl, even though
- it's only a stripped-down version of the first version of Template Toolkit
- it was never meant to be a complete templating system
- Most programmers think that designers make for poor programmers
- Most programmers make for poor designers
Yes, good display logic is expensive. Sometimes, the only way to do something is to drop into a full-featured language. So?
Remember something - a popular templating system for Windows programs written in Visual C++ is Visual Basic.
Being right, does not endow the right to be rude; politeness costs nothing. Being unknowing, is not the same as being stupid. Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence. Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
| [reply] |
|
Re: Re: Re: Re: HTML::Template - what's the rule of thumb?
by punkish (Priest) on Dec 20, 2003 at 16:03 UTC
|
Still I think in the long run, templating systems are a dead branch of the evolutionary tree:
and, some would say, so are we homosapiens... I mean, in the long run we will all be extinct. Let's do it better while we are still alive. ;-).
What I am more intrigued by is...
they are neither pure programs, nor pure mark-up but a hybrid of the two, which IMHO combine the bad things of both for little benefit.
what, in your view, are the "bad things" of programs and mark-up that templating systems combine? I am very curious.
Hybrids are, evolutionarily speaking, almost always stronger than "pure genes" types, and should survive longer than either. Usually hybrids (and, IMHO, definitely H::T) combine the best of two or more types.
Programming is great for utilizing logic to generate content. Mark-up is great for purposing the content for display. Because of the nature of the content, at times a tiny amount of logic creeps into mark-up, but that is ok, because mark-up is greatly enhanced by that logic.
I would say that templating systems are as good a hybrid as Aspirin is. It is not pure Acetyl Salicylate -- in its pure form it would be too sour and probably digest our stomach lining -- and it is not pure starch -- that would be too yucky and useless. But, it is a perfect mixture of the essential acid for its painkiller-ness and the bland base for making it safe and palatable. And very effective at preventing headaches -- just like the templating systems.
Finally, as you rightly said, "whatever works for one, need not work for someone else." In this case, Kiat, the OP seems to find that a templating system works. I commend Kiat on doing the best to separate logic from display using what works.
| [reply] |
|
| [reply] |