So, if you’re a leet php coder, you must have installed Smarty since it gives you a three-tier web application and separates your display logic from your business logic. Right? Maybe not. Just using a template system doesn’t guarantee any of this, so don’t let yourself be deceived in this way.
Before I go further, I’ll confess that I don’t particularly see the point of adding a templating pseudo-language on top of php, which is from the beginning a templating language. But, I recently started using the Savant templating system on my projects. Am I crazy or hypocritical? No, I installed it because a templating system can help you be disciplined about keeping your view and business logic separate and easily manage and change how your web application looks.
What did I run into today that triggered this post? I began debugging an application where something in an input form wasn’t working correctly. There were 3 different types of data that this form could potentially update, but instead of having one input template for each mode, I found one template with a lot of ifs throughout to handle the different modalities. Obviously, a maintenance nightmare and it adds uneccesary complexity if any one input form is supposed to change independent of the others in the future.
So, practice safe templating. More about why templates are evil:
- Smarty is on my evil list – good discussion in comments
- Templates Good or Evil?
- Sitepoing Blogs – Savant Template
- See the Savant2 site for why I chose to try it out.