unset_var for template.inc!
Brought to you by:
nhruby,
richardarcher
Please add a method unset_var("varname/array") to the template engine.
This is required when handling blocks within blocks!!!!
Because in this situation you have sometime to clear already set variables!
Blocks within blocks can be very power- and helpfull but one ran into strange situations when no
unset_var is available.
Its 5 Minutes of work or less!
Thanks.
Logged In: YES
user_id=278685
A unset_var() (or clear_var() as I use in my personal
extension) is simply an alias for set_var("varname", "").
Someone may get around to adding such an alias to the
official library, but it is far less urgent than many
existing bugs.
Logged In: YES
user_id=286352
Sorry to say, but my experience shows that it is not a
simple set_var("name","") because this is different from a
real unset() !
Logged In: YES
user_id=278685
You're correct, there are 2 different issues here. In the case of
embedded blocks, setting the variable to "" is adequate
because the variable is going to be reused immediately -
there's no need to destroy it and then recreate it.
On the other hand, I often use 2 Template instances to
minimize the variables parsed during long loops - in this case
I always do a full unset between loops.
FWIW, I discovered some less-than-ideal programming and
variable use when using an actual unset; setting the variable
to "" covered the problem up.
Logged In: YES
user_id=279311
I've added clear_var method which sets the value of an
variable (or array of variables) to "". Also added an
unset_var method which unsets the variable completely. Use
whichever seems appropriate.
This is in the CVS only at this stage. I also merged the
-devel version of template.inc into the -stable tree. I'm
tired of maintaining two versions.