Хранилища Subversion ant

Редакция

Содержимое файла | Последнее изменение | Открыть журнал | RSS

Редакция Автор № строки Строка
304 alex-w 1
<?php
2
 
3
/**
4
* Smarty Internal Plugin Compile Eval
5
*
6
* Compiles the {eval} tag
7
* @package Smarty
8
* @subpackage Compiler
9
* @author Uwe Tews
10
*/
11
/**
12
* Smarty Internal Plugin Compile Eval Class
13
*/
14
class Smarty_Internal_Compile_Eval extends Smarty_Internal_CompileBase {
15
    /**
16
    * Compiles code for the {eval} tag
17
    *
18
    * @param array $args array with attributes from parser
19
    * @param object $compiler compiler object
20
    * @return string compiled code
21
    */
22
    public function compile($args, $compiler)
23
    {
24
        $this->compiler = $compiler;
25
        $this->required_attributes = array('var');
26
        $this->optional_attributes = array('assign');
27
        // check and get attributes
28
        $_attr = $this->_get_attributes($args);
29
        if (isset($_attr['assign'])) {
30
              // output will be stored in a smarty variable instead of beind displayed
31
            $_assign = $_attr['assign'];
32
        }
33
 
34
        // create template object
35
        $_output = "\$_template = new Smarty_Template ('string:'.".$_attr['var'].", \$_smarty_tpl->smarty, \$_smarty_tpl);";
36
        //was there an assign attribute? 
37
        if (isset($_assign)) {
38
            $_output .= "\$_smarty_tpl->assign($_assign,\$_smarty_tpl->smarty->fetch(\$_template));";
39
        } else {
40
            $_output .= "echo \$_smarty_tpl->smarty->fetch(\$_template);";
41
        }
42
        return "<?php $_output ?>";
43
    }
44
}
45
 
46
?>