Posted: Tue Jul 22, 2003 9:53 am
Been interesting to watch this discussion.
I started off anti template engines but now I'm less so.
The security issues - for example a multiple user CMS or a team of people working on a site whose "permissions" you want to restrict to only what is essential for their job - was something I hadn't thought of.
The smarty paradigm (I think) compiling templates on their first use so they don't have to be parsed on every page load would pretty much remove any objections about efficiency.
I also objected to loops in templates - but, as mentioned in smarty docs, that's presentation logic not business logic and it makes sense to have that in a template.
Still, you'd have to think about the end user: if you build sites for small to medium organisations, you often find that they have (at best) a weak grasp of html: expecting them to cope with a template language any more complicated than a simple {var here} could be too much. Bigger enterprises and more experienced designers would probably be OK with that though.
I suppose this isn't specifically a template engine issue. Instead of template engine loop code, you could use output buffering in the php and a second, mini-template to create a single output var containing rows (forum posts for example). Whether you are parsing with a template engine or simply including html templates you have the same choice to make: one catch-all template with loop code or a main template, buffering & mini-templates with no loop code. Which way to go, I would suggest, depends on the skill level of whoever will be maintaining the live site.
I've recently been re-writing all my code so that all scripts finish with an array of output vars (used to be a real mess with stuff echo'd out all over the place). For the moment I'm extract()'ing these then including html templates where they are all echo'd out, but it would be easy to stick a template engine on the end if required for a particular job.
I started off anti template engines but now I'm less so.
The security issues - for example a multiple user CMS or a team of people working on a site whose "permissions" you want to restrict to only what is essential for their job - was something I hadn't thought of.
The smarty paradigm (I think) compiling templates on their first use so they don't have to be parsed on every page load would pretty much remove any objections about efficiency.
I also objected to loops in templates - but, as mentioned in smarty docs, that's presentation logic not business logic and it makes sense to have that in a template.
Still, you'd have to think about the end user: if you build sites for small to medium organisations, you often find that they have (at best) a weak grasp of html: expecting them to cope with a template language any more complicated than a simple {var here} could be too much. Bigger enterprises and more experienced designers would probably be OK with that though.
I suppose this isn't specifically a template engine issue. Instead of template engine loop code, you could use output buffering in the php and a second, mini-template to create a single output var containing rows (forum posts for example). Whether you are parsing with a template engine or simply including html templates you have the same choice to make: one catch-all template with loop code or a main template, buffering & mini-templates with no loop code. Which way to go, I would suggest, depends on the skill level of whoever will be maintaining the live site.
I've recently been re-writing all my code so that all scripts finish with an array of output vars (used to be a real mess with stuff echo'd out all over the place). For the moment I'm extract()'ing these then including html templates where they are all echo'd out, but it would be easy to stick a template engine on the end if required for a particular job.