By Sibers CTO Andrey Gavrilov
Some time ago I ran across such or similar articles. In general, their idea is that we don’t need template engines in PHP since PHP is template-driven by itself (obviously, in fact, that’s true not only about PHP because there exist JSP, PSP etc. in other technologies). And of course, in all articles of this sort they throw mud at Smarty, the most popular template engine.
So what I am saying is that authors of these articles have no idea what template engines are for. But I agree that Smarty and 90% of similar engines suck because their authors have no idea, too.
A template engine is needed not for separating content from functionality: a good programmer can easily do this in pure PHP. We need templates in order not to allow designers touch any of server functionality – and no Smarty with its too rich feature set can help us here.
If you find this observation far-fetched, I can assure that such a requirement appears in every large project whose specifications I reviewed. No large well-established e-business company can permit their designers staff to get full access to system’s functionality – something that most template engines still allow! Needless to say about sites that allow users setting up their own themes.
Obviously, you can return: if you wanna set up your design, use CSS. That’s all fair, except for the fact that it raises some inconveniences:
- Page should contain all elements that it should display (since design is applied on client’s side). As a result, you get cumbersome dinosaur-like htmls.
- If a CSS file hasn’t loaded for any reason, you see something frightful. Think of large pages that are shown underloaded with all hidden elements that are displayed until CSS is loaded.
- For proper customization, it’s vital to use div-based design that not everyone likes.
So, an ideal template engine is the one that allows working only with data that was fed into it – and nothing more.
I am contacting you through this contact form as there was no email address available. We would be interested in purchasing advertising on your blog. Please get back to me using the email address I have entered if you would be interested in discussing this further.