I wonder what options there are for templating in PHP? If the templating code can be very similar to PHP, it'd be best.
+4
A:
I can recommend Smarty
The template is a plain HTML with some extra markup for PHP calls. The template compiles itself to a PHP and runs on the server.
pgb
2009-05-17 16:12:53
Worth mentioning that smarty has some pretty powerful server-side caching.
karim79
2009-05-17 16:16:15
+4
A:
there is an "alternative" syntax to php that makes it more attractive amidst html tags, I can highly recommend it.
Short tags, though mostly discouraged and/or ridiculed also have a nice advantage:
<?php echo $variable; ?>
can become:
<?= $variable; ?>
And you can do stuff like:
<ul>
<? foreach ( $myListItems as $id => $itemText ) : ?>
<li id="<?= $id; ?>">
<?= $itemText; ?>
</li>
<? endforeach; ?>
</ul>
Which is the lowest level templating you are going to achieve with php, but is still very readable and it does not require you to mix in controller or model logic with your view.
Kris
2009-05-17 16:24:07