RE: Smarty and speed
| From: | Pablo | Date: | Fri, 07 Dec 2001 19:18:30 +0000 |
| Subject: | RE: Smarty and speed | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2203@lists.php.net to get a copy of this message | ||
Thank you for the detailed response.
So if I may summarize...
Smarty is simply replacing PHP tags to bring things together in a
comprehensive package (like caching, config vars, etc.) and makes the syntax
cleaner for designers.
Would that be an accurate summary of the reasons to use Smarty?
Again, not trying to ruffle feathers. I just like to look at things from an
academic perspective.
To be honest, I still find it hard to make the argument for Smarty. A
cleaner syntax and built-in caching is nice. But how do I convince a team
of people to adopt it just because the syntax is less terse? There has to
be a killer reason... That's what I cannot seem to find. :(
Side Note: It's interesting that Rasmus originally wrote PHP as a
templating solution for HTML. He wanted tags in order to be able to apply
layout logic to his HTML code. According to Rasmus, PHP IS a templating
language. So based on that premise, Smarty competes with PHP. Especially
since Smarty is also designed to handle "layout logic". Just a little
trivia for you...
Thanks,
Pablo
-----Original Message-----
From: mohrt@ns3.ispi.net [mailto:mohrt@ns3.ispi.net]On Behalf Of Monte Ohrt
Sent: Friday, December 07, 2001 1:54 PM
To: smarty@lists.ispi.net
Cc: smarty@lists.ispi.net
Subject: [smarty] RE: Smarty and speed
Pablo wrote:
>
> 1. Smarty allows me to "compile" templates to PHP.
> a. If I used PHP from the beginning there is no need for this.
Yep, and the template syntax would become quite terse for the designer.
What would you rather see:
<table>
{section name=foo loop=$bar}
<tr><td>{$bar[foo].name}</td></tr>
{sectionelse}
<tr><td>nothing</td></tr>
{/section}
</table>
or this:
<table>
<?php if( count($bar) > 0) {
for( $foo=0; $foo < count($bar); $foo++ ) {
?> <tr><td><?php echo $bar[$foo]['name'];
?></td></tr> <?php
} else {
?> <tr><td>nothing</td></tr> <?php
} ?>
</table>
> 2. Smarty allows me to cache the PHP pages in HTML.
> a. If I am writing dynamic database driven sites so I probably won't want
> this anyway.
In most cases, there is dynamic content that is exactly the same each
time you load a page. It is much more efficient to cache this
information instead of creating it each time.
> Plus, it's not that far fetched to write a caching routine for regular
> PHP/HTML files.
Sure, you can write anything in PHP ;-) The cache engine in Smarty is
tightly integrated, thus more powerful than just a caching wrapper.
> 3. Smarty allows me to include other templates inside the current template
> using the "include" tag
> a. PHP allows me to do the exact same thing using the "include" statement.
Of course PHP can do any functionality Smarty can do, it is the language
Smarty was written in :-)
> 4. Smarty is a little hard to learn (sections) at first, but once you get
it
> you're off and running.
> a. I already know PHP.
Yes, _you_ already know PHP. Not so easy for the newcomer, and not the
most elegant language as a templating syntax.
> 5. Smarty allows you to write custom tags.
> a. With PHP you can create new functions or classes.
See point 3
> 6. Smarty allows if/elseif/else/endif construct for conditions.
> a. PHP does too. And also offers a bit more :)
>
See point 3
---
You are currently subscribed to smarty as: phpshop@phpshop.org
To unsubscribe send a blank email to $subst('Email.Unsub')
Visit Smarty's homepage at http://www.phpinsider.com/php/code/Smarty/