Hacker News new | ask | show | jobs
by pwoods 6435 days ago
So is anyone using Smarty anymore? Or is this short form php now all the rage? Just curious because I'd update if it was.
3 comments

I could never understand the advantage of using a templating system inside another templating system. Smarty has loops. PHP has loops. Did I miss the train?
Smarty produces slightly cleaner code but is worthless otherwise IMHO.
It's adding an extra layer of work which is unnessacary unless you're handing templates to people who really can't do PHP. If your designers are working on the HTML use Smarty tbh.
I use smarty mainly for it's templating benefits. Also you can write your own custom functions to call from the template files if needed, I found this to be very handy.
I've used smarty extensively at work, but I've always felt like I was fighting with the iteration constructs and odd choice of syntax.

I've always hated that in smarty, associative arrays are accessed with a dot. Associative array indices don't have to be valid php variable names, so what happens when you want to access $user['home-address'] in smarty?

With Smarty 2.x you're left needing to do something like: {assign var=foo value="some string"} {$user[$foo]}

Smarty 3.x has a legitimate lexer/parser so the templates will be much more flexible. I think they finally realized that since they are compiling the templates anyway the parsing can be slow.

Smarty is awesome, but a little dated. They are finally working on 3.0 alpha which will have much better php5 support.

http://smarty.net

Even as is though, it is worth using.