Teach me about Smarty Templates!

Well I just did a google search and found this: http://www.smarty.net/crashcourse.php

First time I've heard of it but it looks like it could be quite useful. It sort of allows you to seperate the view (html page) from the model (back end database) without tangling raw php in with html.
 
I use dom generation rather than smarty. a lot of people say it's less friendly to people who only know php, but I've never worked with an html developer who couldn't grasp how to use it.

and psyreen is right.
 
I'm interested to hear your reasons for disliking it, psyr33n and Sic. I don't really use it anymore, but I never had any real reason to dislike it when I was.
 
It's bloated. I used it quite intensively a few years ago, but came to the simple realistation that it's far more efficient, and easier, to just use php to do what smarty does.

The argument of designer vs code is complete crap. The designer gave you a few html files? OH NOES! I as a developer am completely incapable of writing my php code to output the same markup! I must use a template engine!!11

Besides which, I'm yet to meet a designer who does use HTML and not Photoshop/Fireworks/etc to actually design.. then leave the markup to the developer.
 
It's bloated. I used it quite intensively a few years ago, but came to the simple realistation that it's far more efficient, and easier, to just use php to do what smarty does.

The argument of designer vs code is complete crap. The designer gave you a few html files? OH NOES! I as a developer am completely incapable of writing my php code to output the same markup! I must use a template engine!!11

Besides which, I'm yet to meet a designer who does use HTML and not Photoshop/Fireworks/etc to actually design.. then leave the markup to the developer.

The way I used to use it was to create a wireframe site with basic functionality using Smarty for the templates, and then hand it over to the designer - with the idea being that it would be less scary / easier to read for them if there was no hard PHP in the file.

I've come around to the opinion that the only real valuable part is the logic / presentation separation and if you've already got that with an MVC framework (ala Symfony) then Smarty is pretty much redundant.

PS - the caching is also handy but again, this is usually included in most frameworks.
 
Caching is, in my opinion at least, not a viable reason to use Smarty. Caching is very, very easy to implement with just a handful of lines of code.

One thing I've realised that Smarty (or other template engine) *is* good for, is CMS - allowing the user to change the markup of a page relatively safely. I seem to remember that there was a {php} tag in smarty that allowed you to input php, but it seems to have been removed.
 
Back
Top Bottom