On 08/04/2004, at 11:35 AM, Kelly Hallman wrote:

Apr 8 at 10:26am, Justin French wrote:
PHP itself is a great templating language :)
<h1><?=$title?></h1>
<table>
<? foreach($staff as $person): ?><tr>
<td><?=$person['firstname']?> <?=$person['surname']?></td>
<td><?=$person['role']?></td>
<td><?=$person['phone']?></td>
<td><a href='mailto:<?=$person['email']?>'><?=$person['email']?></td>
</tr><? endforeach; ?></table>

Uhhh, yeah--that's not a templating, that's called spaghetti code :)

I fail to see the difference in complexity. Taking an example straight form the smarty docs:


<table>
{section name=mysec loop=$users}
{strip}
   <tr bgcolor="{cycle values="#aaaaaa,#bbbbbb"}">
      <td>{$users[mysec].name}</td>
      <td>{$users[mysec].phone}</td>
   </tr>
{/strip}
{/section}
</table>

Looks the same to me as:

<table>
<? foreach($users as $user): ?>
   <tr bgcolor="<?cyle('#eeeeee','#dddddd');">
      <td><?=$user['name']?></td>
      <td><?=$user['phone']?></td>
   </tr>
<? endforeach; ?>
</table>

(yes, I wrote a cycle() function in about 30 seconds)

I guarantee another person not as adept at PHP will screw that code up,
and there is less potential for that with a Smarty template. If you know
PHP as well as yourself, it should be plain to see how Smarty is just a
wrapper over PHP that makes templates easier to build and maintain.
For a designer or non-coder, Smarty will be easier to learn than PHP.

Not in my experience. Smarty lies somewhere in between a programming language and pseudo tags... In *my* experience training template designers...
{section name=mysec loop=$users}
was more confusing than:
<?foreach($users as $user): ?>


Your mileage may vary, of course, but that's not my point.


Unless your needs never exceed the very basics like you have demonstrated
above, you'll be hosed when another person needs to modify your template.
Which goes back to a templating truism never in dispute: if this is all
you want templating for, it's six of one, half a dozen of the other.


However, there are practical limitations on what you can easily accomplish
with this approach, and Smarty addresses those issues. And you're worse
off if you invest a lot into building your sites this way, and then
realize you need some better templating strategies later.

WHAT??? Are you suggesting that smarty templates are MORE EXTENSIBLE than straight PHP???


This is exactly my point. If you run with Smarty, you're LOCKED IN to that language virtually forever. Anything Smarty can do, I can replicate with PHP (obviously), plus a whole heap more. Smarty adds a layer of limitations and simplicity to your templates, but at huge cost:

You're locked into a proprietary templating language. When that language fails to deliver everything you want/need, you have no where to go.

A agree Smarty is fantastic at imposing limitations on it's templates, but this is it's strength AND it's weakness.

You can consider it it's own language, but really it's more like PHP with
different formatting. Which is why it's different than what you're doing
above--it's designed to facilitate templating. Your method is just poking
in variables and PHP into inline'd HTML. It works, but you're missing some
of the power of Smarty if you think that's all it's good for.

I agree, there's more to smarty, but in the end, it's just an interface to PHP -- eventually you will hit the wall with the functionality that the interface allows. Pure PHP templates however will only ever be limited by PHP itself.


In other words: are your template designers already good PHP programmers?
It's not just hype, it solves real problems, even if you don't have them.

As stated, this was not a problem for me, but it IS a problem for some. Smarty is not a solution to every world problem. It has it's place for sure, but I felt the need to point out that PHP alone is a great templating language, with limitless functionality.


It's up to the OP to take this thread and decide what he/she will do next.

---
Justin French
http://indent.com.au

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to