Could you elaborate? What happened to Smarty during those years?
Could you elaborate? What happened to Smarty during those years?
One of the core arguments against it, I think, was PHP developers suddenly remembering short tags and alternative syntaxes for control structures (if, foreach) that made working with templates in straight PHP just as easy, much more flexible, and shaving a few milliseconds off load times -- it's a sizeable library to load.
<?php echo htmlentities($name); ?>
In Django templates: {{ name }}
Things get a bit better if you write your own "h" function: function h($var) { echo htmlentities($var); }<?= $name ?> is my preferred method of printing inline, which shortens it up quite a bit.
<?= h($name) ?>
Which isn't that terrible.The PHP developers don't make this easy though, as "short tags" are officially recommended to be disabled, so to write portable PHP you'd have to do
<?php= h($name) ?>
Every time, which adds visual noise that gets worse the more tags you write.<?= htmlentities($name) ?> is a lot better...
We have to have an i18n layer anyway for all output so it ends up being a lot of <?= Msg('message-name') ?> calls. Use some code gen macros and it's tolerable.
Also, XHP seems pretty rad. It gives me ideas. :)
<?= htmlentities($name, ENT_QUOTES, 'UTF-8'); ?>Giving them a template file with something like {$CustomerFirstName}. Which they can then move around without fear of breaking the page makes sense.
And let's be honest there aren't that many websites in the world which have to really worry about the performance implications of using smarty.
There are also nice little shortcuts in Smarty, like wrapping templates in {strip}{/strip} to strip newlines and whitespace which would be tricky in PHP without using output buffering.
But aside of all of that, the 3rd version of Smarty puts it back on the right track.