What’s Smarty?

Six months later… and I don’t miss Smarty at all. I’m perfectly happy with Zend Framework’s view scripts and PHP’s alternate syntax tags. Accepting view scripts was easy enough, it’s part of the framework so I might as well use it. However I still couldn’t accept seeing PHP code in my HTML templates:

<table>
<?php foreach($tableData as $dataRow) { ?>
   <tr>
   <?php foreach($dataRow as $data) { ?>
      <td><?php echo $data; ?></td>
   <?php } ?>
   </tr>
<?php } ?>
</table>

When I discovered PHP’s alternate syntax, it just made sense. Especially if one keeps the alternate syntax in the view script only. And I think the syntax itself is much easier for The Designer (who doesn’t know/care about anything that is PHP) to understand:

<table>
<? foreach($tableData as $dataRow): ?>
   <tr>
   <? foreach($dataRow as $data): ?>
      <td><?= $data ?></td>
   <? endforeach; ?>
   </tr>
<? endforeach; ?>
</table>

And at the same time I don’t get asked those endless ‘what the hell does {section} mean?’ questions anymore.

Comments

Leave a Reply