Hacker News new | ask | show | jobs
by grey-area 5014 days ago
Those features are a persuasive argument against smarty as a template language.

One of the worst flaws of php is that it makes it easy to mix up code and the view, which is ok if you're writing a single page, and terribly dangerous if you're writing anything more complex.

I've experienced this myself writing templates for things like phpbb (thankfully not something I do frequently) - every time the forum updates, the templates have to be patched again - they even have a weird patching system to try to work around the issue with code in views.

A better template language would actually limit the amount you can do in your view files to the bare minimum - something like mustache comes to mind. If you want to keep the views maintainable, easy to swap out, and easy to add alternatives to like json or XML as well as HTML, the aim should be to reduce the lines in your codebase by putting the filters, caching and logic around your views in helpers rather than inside your views.