- improve compiled code

This commit is contained in:
uwetews
2015-10-24 05:16:54 +02:00
parent 891495f849
commit b7fb490cb1
2 changed files with 8 additions and 7 deletions

View File

@@ -43,7 +43,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
/** /**
* Compiles code for the {include_php} tag * Compiles code for the {include_php} tag
* *
* @param array $args array with attributes from parser * @param array $args array with attributes from parser
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
* *
* @return string * @return string
@@ -103,7 +103,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
} }
if (isset($_assign)) { if (isset($_assign)) {
return "<?php ob_start(); include{$_once} ('{$_filepath}'); \$_smarty_tpl->assign({$_assign},ob_get_contents()); ob_end_clean();?>"; return "<?php ob_start();\ninclude{$_once} ('{$_filepath}');\n\$_smarty_tpl->assign({$_assign},ob_get_clean());\n?>";
} else { } else {
return "<?php include{$_once} ('{$_filepath}');?>\n"; return "<?php include{$_once} ('{$_filepath}');?>\n";
} }

View File

@@ -60,7 +60,8 @@ class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Inter
// maybe nocache because of nocache variables or nocache plugin // maybe nocache because of nocache variables or nocache plugin
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache; $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
// compile code // compile code
$output = "<?php \$_smarty_tpl->smarty->_cache['tag_stack'][] = array('{$tag}->{$method}', {$_params}); \$_block_repeat=true; echo \$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>"; $output =
"<?php \$_smarty_tpl->smarty->_cache['tag_stack'][] = array('{$tag}->{$method}', {$_params}); \$_block_repeat=true; echo \$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
} else { } else {
$base_tag = substr($tag, 0, - 5); $base_tag = substr($tag, 0, - 5);
// must endblock be nocache? // must endblock be nocache?
@@ -76,11 +77,11 @@ class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Inter
$mod_pre = $mod_post = ''; $mod_pre = $mod_post = '';
} else { } else {
$mod_pre = ' ob_start(); '; $mod_pre = ' ob_start(); ';
$mod_post = 'echo ' . $mod_post = 'echo ' . $compiler->compileTag('private_modifier', array(),
$compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter['modifier_list'], array('modifierlist' => $parameter['modifier_list'],
'value' => 'ob_get_clean()')) . ';'; 'value' => 'ob_get_clean()')) . ';';
} }
$output = "<?php \$_block_content = ob_get_contents(); ob_end_clean(); \$_block_repeat=false;" . $mod_pre . $output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;" . $mod_pre .
" echo \$_smarty_tpl->smarty->registered_objects['{$base_tag}'][0]->{$method}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); " . " echo \$_smarty_tpl->smarty->registered_objects['{$base_tag}'][0]->{$method}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); " .
$mod_post . " } array_pop(\$_smarty_tpl->smarty->_cache['tag_stack']);?>"; $mod_post . " } array_pop(\$_smarty_tpl->smarty->_cache['tag_stack']);?>";
} }