| Dennis Freise 2004-07-06, 4:11 pm |
| Hi everyone.
I've a question concerning the execution time of an {eval ...} command...
I have a site which uses many templates, and I have the following:
template 1:
{capture name=post_item}
{literal}
a typical post_block with {$vars} and {if expressions} in it
{/literal}
{/capture}
template 2:
{include file="template1"}
{section name=items loop=$post_items}
{eval var=$smarty.capture.post_item}
{/section}
Containing 10 posts on one page, this takes about 0.3 secs to compile on my
server.
If I change the templates to:
template 1:
a typical post_block with {$vars} and {if expressions} in it
template 2:
{section name=items loop=$post_items}
{include file="template1"}
{/section}
Now the page compiles in ~0.06 secs. Thats 5 times less than the
{capture}-{eval} approach.
Anyone who could clarify what's causing smarty to take so long to compile the
first variant, please ? Which one is to be preferred if the templates come from
a db, and the number of db-queries is important for performance ?
Thanks in advance, Dennis.
--
Dennis Freise <cat@final-frontier.ath.cx>
GnuPG key: 2DE8 CCEF 6E20 11D4 3B27 21EC B0BA 1749 D2C8 38ED
Available at: http://www.final-frontier.ath.cx/?key-plain
|