Chris PeBenito 696b41
Chris PeBenito 696b41
/**
Chris PeBenito 696b41
 * Smarty plugin
Chris PeBenito 696b41
 * @package Smarty
Chris PeBenito 696b41
 * @subpackage plugins
Chris PeBenito 696b41
 */
Chris PeBenito 696b41
Chris PeBenito 696b41
/**
Chris PeBenito 696b41
 * Smarty {assign} compiler function plugin
Chris PeBenito 696b41
 *
Chris PeBenito 696b41
 * Type:     compiler function
Chris PeBenito 696b41
 * Name:     assign
Chris PeBenito 696b41
 * Purpose:  assign a value to a template variable
Chris PeBenito 696b41
 * @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign}
Chris PeBenito 696b41
 *       (Smarty online manual)
Chris PeBenito 696b41
 * @param string containing var-attribute and value-attribute
Chris PeBenito 696b41
 * @param Smarty_Compiler
Chris PeBenito 696b41
 */
Chris PeBenito 696b41
function smarty_compiler_assign($tag_attrs, &$compiler)
Chris PeBenito 696b41
{
Chris PeBenito 696b41
    $_params = $compiler->_parse_attrs($tag_attrs);
Chris PeBenito 696b41
Chris PeBenito 696b41
    if (!isset($_params['var'])) {
Chris PeBenito 696b41
        $compiler->_syntax_error("assign: missing 'var' parameter", E_USER_WARNING);
Chris PeBenito 696b41
        return;
Chris PeBenito 696b41
    }
Chris PeBenito 696b41
Chris PeBenito 696b41
    if (!isset($_params['value'])) {
Chris PeBenito 696b41
        $compiler->_syntax_error("assign: missing 'value' parameter", E_USER_WARNING);
Chris PeBenito 696b41
        return;
Chris PeBenito 696b41
    }
Chris PeBenito 696b41
Chris PeBenito 696b41
    return "\$this->assign({$_params['var']}, {$_params['value']});";
Chris PeBenito 696b41
}
Chris PeBenito 696b41
Chris PeBenito 696b41
/* vim: set expandtab: */
Chris PeBenito 696b41
Chris PeBenito 696b41
?>