RE: Smarty and speed

From: Date: Fri, 07 Dec 2001 20:18:00 +0000
Subject: RE: Smarty and speed
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2206@lists.php.net to get a copy of this message
Thank you very much. I hope I did not give the impression that I am questioning the use of a templating system. I realize the benefits to this very well. What I cannot see is the benefit (at least for my purposes) of the way Smarty handles templating. It seems to me that it is a scripting language all of it's own. It's a subset of commands that are specific to content and layout logic. So it's like PHP, just smaller! :) It's especially clear now that you explained the 3rd party clients and your wish to not allow them to run PHP. That makes total sense. But it seems that the argument is still mute for me. I realize that this is your baby and my intention is not to dissect it in a negative way. It's simply that I have to make an important decision and this is part of the process. Your other email: > Maybe this is a fair example: Why use PHP when you can use C? You can do > everything PHP does in C and even more, can't you? That's not a fair comparison. C is not a templating language. Also, to use C it would be compiled and not interpreted. Not the same as PHP. But I appreciate your analogy. It's just that I would probably have compared PHP with ASP. That may be a better comparison! Thanks for the valuable feedback! Pablo -----Original Message----- From: mohrt@ns3.ispi.net [mailto:mohrt@ns3.ispi.net]On Behalf Of Monte Ohrt Sent: Friday, December 07, 2001 2:31 PM To: Pablo Cc: smarty@lists.ispi.net Subject: Re: [smarty] RE: Smarty and speed Pablo wrote: > > 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? Yes, along with numerous other things such as separation of content and layout and managability of applications. > > 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. :( I think there are lots of reasons why a templating solution is desired. I'm not about to write a white paper myself, but look at the introduction in the documentation, and many many threads about this in various mailing lists. It can be a vicious circle. Let me ask you now: Are you better off writing your applications without Smarty? Why or why not? Every case is different. In our particular case, we have third party clients editing the template files. Not only do we want to make this as easy as possible, we do NOT want them executing PHP code on the servers. The templates/configs are totally isolated on the system. > > 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... Nothing I'm not aware of ;-) > > 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/ -- Monte Ohrt <monte@ispi.net> http://www.ispi.net/

« previous php.smarty.general (#2206) next »