|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
mimos Smarty Rookie
Joined: 15 Oct 2016 Posts: 7
|
Posted: Fri Mar 06, 2020 12:11 am Post subject: Optimized subtemplate compilation with nocache variables |
|
|
Hi,
I stumbled upon the following case where I could change the code to a version with worse readability/usability to get an optimized result. I think in this case smarty could maybe automatically do the optimization itself so using the nicer code would be possible:
First the version with the nice code:
php code:
Code: |
include ...;
$smarty = new Smarty;
$smarty->caching = true;
$smarty->debugging = true;
$smarty-assign('uncached', 'test', true);
$smarty->display('template.tpl');
|
template.tpl:
Code: |
{include file="subtemplate.tpl" other_name=$uncached}
|
subtemplate.tpl:
When I run this I see the two templates seperately in the debug view every time, so the subtemplate afaik gets loaded separately every time.
To optimize that I can change template.tpl:
Code: |
{assign "other_name" $uncached}
{include file="subtemplate.tpl"}
|
Now the debug window only shows template.tpl so the subtemplate gets integrated into it which should be better for the loading times.
I'd be happy if you could teach smarty to get the same result using the nicer code from the top .
Thanks,
Mimos |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Mar 09, 2020 1:29 am Post subject: |
|
|
That's not quite true. All templates are cached separately, unless you explicitly ask for inline include. However, since your "subtemplate" contains a "nocache" variable, it won't get cached.
Instead of guessing from debug console output, just go down the Smarty cache path and look at the templates cached. |
|
Back to top |
|
mimos Smarty Rookie
Joined: 15 Oct 2016 Posts: 7
|
Posted: Fri Aug 21, 2020 4:25 pm Post subject: |
|
|
Sorry for replying this late. Thanks for your explanations and sorry for my unneeded post. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|