PageRenderTime 16ms CodeModel.GetById 13ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/framework/vendor/smarty3/lib/libs/sysplugins/smarty_internal_compile_eval.php

http://zoop.googlecode.com/
PHP | 46 lines | 21 code | 3 blank | 22 comment | 3 complexity | f2c5718e38222a8fcb205760b9296007 MD5 | raw file
 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*/ 
14class 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 {$compiler->smarty->template_class}('string:'.".$_attr['var'].", \$_smarty_tpl->smarty, \$_smarty_tpl);"; 
36        //was there an assign attribute? 
37        if (isset($_assign)) {
38            $_output .= "\$_smarty_tpl->assign($_assign,\$_template->getRenderedTemplate());";
39        } else {
40            $_output .= "echo \$_template->getRenderedTemplate();";
41        } 
42        return "<?php $_output ?>";
43    } 
44} 
45
46?>