News for hackers. Stuff that matters.
Re:Ask HN: PHP Tricks and Best Practices? by pwoods on Wednesday October 29, 2008 @02:13PM (#347754)
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.
Re:Ask HN: PHP Tricks and Best Practices? by bprater on Wednesday October 29, 2008 @03:19PM (#347857)
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?
Re:Ask HN: PHP Tricks and Best Practices? by kwamenum86 on Wednesday October 29, 2008 @07:00PM (#348150)
Smarty produces slightly cleaner code but is worthless otherwise IMHO.
Re:Ask HN: PHP Tricks and Best Practices? by RossM on Thursday October 30, 2008 @07:08AM (#348613)
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.
Re:Ask HN: PHP Tricks and Best Practices? by louislouis on Wednesday October 29, 2008 @07:36PM (#348195)
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.
Re:Ask HN: PHP Tricks and Best Practices? by ericwaller on Wednesday October 29, 2008 @02:25PM (#347780)
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?

Re:Ask HN: PHP Tricks and Best Practices? by JoelSutherland on Wednesday October 29, 2008 @05:02PM (#348014)
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.

Re:Ask HN: PHP Tricks and Best Practices? by JoelSutherland on Wednesday October 29, 2008 @02:28PM (#347786)
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.