3 * Smarty Internal Plugin Nocache Insert
\r
5 * Compiles the {insert} tag into the cache file
\r
8 * @subpackage Compiler
\r
13 * Smarty Internal Plugin Compile Insert Class
\r
16 * @subpackage Compiler
\r
18 class Smarty_Internal_Nocache_Insert {
\r
21 * Compiles code for the {insert} tag into cache file
\r
23 * @param string $_function insert function name
\r
24 * @param array $_attr array with parameter
\r
25 * @param Smarty_Internal_Template $_template template object
\r
26 * @param string $_script script name to load or 'null'
\r
27 * @param string $_assign optional variable name
\r
28 * @return string compiled code
\r
30 public static function compile($_function, $_attr, $_template, $_script, $_assign = null)
\r
32 $_output = '<?php ';
\r
33 if ($_script != 'null') {
\r
34 // script which must be included
\r
35 // code for script file loading
\r
36 $_output .= "require_once '{$_script}';";
\r
39 if (isset($_assign)) {
\r
40 $_output .= "\$_smarty_tpl->assign('{$_assign}' , {$_function} (" . var_export($_attr, true) . ",\$_smarty_tpl), true);?>";
\r
42 $_output .= "echo {$_function}(" . var_export($_attr, true) . ",\$_smarty_tpl);?>";
\r
45 while ($_tpl->parent instanceof Smarty_Internal_Template) {
\r
46 $_tpl = $_tpl->parent;
\r
48 return "/*%%SmartyNocache:{$_tpl->properties['nocache_hash']}%%*/" . $_output . "/*/%%SmartyNocache:{$_tpl->properties['nocache_hash']}%%*/";
\r