[prev in list] [next in list] [prev in thread] [next in thread] 

List:       smarty-dev
Subject:    [SMARTY-DEV] assign by reference
From:       198.237.84.162
Date:       2002-07-25 3:55:21
[Download RAW message or body]

Would be nice to use a reference so that changes to the variable can be made
during Smarty template processing.
In our case, we assign() our Application object to smarty when we
instantiate smarty. Many configuration changes
happen to the App object after the assignment before template processing.
Those changes cant be seen because
smarty stored a copy of the variable.

It would be nice to allow smarty to assign by reference in such instances.
Performance buffs would/should use this method regardless to reduce the
memory overhead of copying the variable. However, this would remove the
capability to use an array in the assignment, since you cant assign a
default value in the function definition for values passed by reference.


/*======================================================================*\
    Function:   assign_by_ref()
    Purpose:    assigns values to template variables using references
    Parameters: $tpl_var - Name of the variable
                       $value - A reference to the variable contents
\*======================================================================*/
    function assign_by_ref($tpl_var, &$value)
    {
        if ($tpl_var != '' && isset($value))
           $this->_tpl_vars[$tpl_var] = &$value;
        $this->_extract = true;
    }



-- 
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic