|
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 |
youngfish Smarty n00b
Joined: 28 Jul 2003 Posts: 2
|
Posted: Mon Jul 28, 2003 4:46 am Post subject: A question about Smarty |
|
|
Hi, if I have a variable assigned in the Smarty class.
But I didn't use it in the template.
(It seems like a waste but I have my own consideration)
My question is:
Will smarty optimize compiling the code?
(I mean
will smarty delete those PHP codes associated with assigning
the value of unused variables.)
Anyone knows more info about that please let me know.
Thanks in advance. |
|
Back to top |
|
CirTap Smarty Pro
Joined: 04 Jun 2003 Posts: 106
|
Posted: Tue Aug 05, 2003 5:53 pm Post subject: |
|
|
Hi,
as far as I can see from the individual compiled files, they will contain only the variables that are {$used} inside the corresponding template, but I think messju can tell you all the dirty details
So if you [php:1:7a2b810ea4]$smarty->assign('var1', 'bla');
$smarty->assign('var2', 'blubb');
$smarty->assign('var3', 'blipp');[/php:1:7a2b810ea4]
and your template has Quote: | <p>{$var1}</p>
<p>{$var3}/p> |
the compiled file will only attempt to "echo" var1 and var3. *This* file is based on what's in the .tpl file not what might be in $smarty->_tpl_vars[]
This does not mean that $smarty->_tpl_vars[] itself can be bloaded with garbage unless you use $smarty->is_cached() to conditionally fill it up.
The compiled files will the "echo" what's available at runtime.
You don't have to bother with undefined variables (my favorite<g>), e.g using {$gaga}, without having called $smarty->assign('gaga', ..) in your files.
Smarty will silently ignore the void, but because you had it in the .tpl you'll find it in compiled file... it may have a value the next time the page is loaded.
Does this answer your question?
CirTap |
|
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
|