Reputation: 151036
I wonder what options there are for templating in PHP? If the templating code can be very similar to PHP, it'd be best.
Upvotes: 0
Views: 297
Reputation: 41837
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.
Upvotes: 4