in reply to Re: Re: The scope of templates
in thread I need a title - sucka! :-)
That said, I agree with your list of what matters and where the dangers are, but disagree with your ideas on how to get there. My general perspective on what should feed templating decisions can be found at Re (tilly) 6: Code Critique. The biggest single factor in most cases is that your decisions here determine who must necessarily be involved in different kinds of maintainance going forward. To me this fact is massively more important than factors such as how dynamic the content of the site is.
Both of these are a bit dated, but I still like the overview offered by this white paper on Template::Toolkit and Choosing a Templating System. The second one has an update coming, so you should talk to perrin about any templating-like system (eg Text::Vpp) that you like, telling him how it works, and why you like it.
The overhead offered by a good templating system is miniscule. For instance it is not a good bet that heredocs are going to be faster at runtime. But it is a good bet that the decision to use heredocs guarantees that pretty much anything involving touching HTML will need to involve a programmer, and anything involving changing the overall layout of the page will likely involve tearing your hair out. (CSS can only do so much of that for you on a complex site. Try rearranging what pages have what content and...)
It is also far from guaranteed that the decision to use a templating system will result in your winding up with well-defined data components that HTML people can manipulate without having to learn how to program. But you have a chance to get there if that is your up front goal and it really makes sense with how your company is organized.
So my personal opinion is that while heredocs are sometimes justified (I have certainly sometimes used them, particularly in cases when I will be the only maintainer and what the script does is simple), choosing to go that way limits the tradeoffs that you can decide to make. And normally there is a better tradeoff available which can be reached with a templating system.
Of course the flip side is that reaching the right tradeoff will also mean having the programmers only using the extra expressiveness that the templating system offers to express the solution that you want..and no more. Unwarranted further use of available expressiveness is an option that I agree can quickly lead to a big ball of mud. But there is no reason why it can't remain just that, an unused option.
|
|---|