RE: Smarty and speed
| From: | Monte Ohrt | Date: | Fri, 07 Dec 2001 18:54:27 +0000 |
| Subject: | RE: Smarty and speed | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2202@lists.php.net to get a copy of this message | ||
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