Kelly Hallman said:
> Apr 6 at 2:43pm, Chris de Vidal wrote:
>> Given that scripts are compiled the first time they're ran, you'll
>> never* notice the bloat and never lack performance; it's the same as
>> real PHP code and can be optimized with a caching engine like Zend.
>
> Certainly. However, the Smarty compiler is about 2200 lines of code, and
> the Smarty class itself (which does load every time) is about 2000. Both
> figures rounded up, and both files contain heaps of comments.

Ahh never thought about that.

> Still, many people consider this bloat, if they're merely wanting to
> search and replace a couple of values on an HTML template.

Yep, I was given something simple on this mailing list for this task. 
Looked perfect -- at first -- but I recognized I was going to need more
(if/then and loops) so I used Smarty instead.  But here is a very simple
template engine:
http://marc.theaimsgroup.com/?l=php-general&m=107644142420608&w=2

>> Instead, I put something like this in the template:
>> {if $level > 2}{bio}{/if}
>
> Again, take it a step further and you may just load up a $User object (of
> your design) within your PHP code. Then in the template, you could use:
>
> {if $User->hasPermission('write')} ... {/if}
>
> When you start thinking like this, your PHP logic gets very slim and easy
> to read and maintain. This is the goal and benefit of templating.

Sweet!

> It becomes especially powerful when working on a larger web app. You
> needn't assign your values into the template from each PHP page. You can
> make a boilerplate include and assign common variables as references:
>
<code snipped>
>
> So you can attach references right off the bat in an include, then every
> time you use that include, you've already got things assigned and can
> change them all you want before displaying, without additional assignment.
>
> Going even one step further (the beauty of Smarty: always another level),
> just extend the Smarty object itself. Then, instead of making all your
> templates includes other templates (such as a header or a footer), you can
> make your overall page be a template, and the extended Smarty object can
> be given extra functionality to control the page:
>
<code snipped>
>
> Now, is Smarty awesome, or what? :)

I don't quite understand what you're saying because I'm feeling ill at the
moment :-P so I'll have to try to comprehend it later.

But thanks for the enthusiasm!

/dev/idal

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

Reply via email to