- improvement remove not needed ?><?php transitions from compiled code

This commit is contained in:
Uwe Tews
2015-05-16 14:17:59 +02:00
parent 0bdd805d6b
commit 22bccee350
2 changed files with 194 additions and 161 deletions

View File

@@ -162,6 +162,25 @@ class Smarty_Internal_Templateparser
{
$this->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($this, $code));
}
/**
* merge PHP code with prefix code and return parse tree tag object
*
* @param string $code
*
* @return Smarty_Internal_ParseTree_Tag
*/
public function mergePrefixCode($code)
{
$tmp ='';
foreach ($this->compiler->prefix_code as $preCode) {
$tmp = empty($tmp) ? $preCode : $this->compiler->appendCode($tmp, $preCode);
}
$this->compiler->prefix_code=array();
$tmp = empty($tmp) ? $code : $this->compiler->appendCode($tmp, $code);
return new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp,true));
}
}
%token_prefix TP_
@@ -223,8 +242,7 @@ template ::= .
// Smarty tag
template_element(res)::= smartytag(st) RDEL. {
if ($this->compiler->has_code) {
$tmp =''; foreach ($this->compiler->prefix_code as $code) {$tmp.=$code;} $this->compiler->prefix_code=array();
res = new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp.st,true));
res = $this->mergePrefixCode(st);
} else {
res = null;
}
@@ -805,7 +823,8 @@ value(res) ::= varindexed(vi) DOUBLECOLON static_class_access(r). {
// Smarty tag
value(res) ::= smartytag(st) RDEL. {
self::$prefix_number++;
$this->compiler->prefix_code[] = '<?php ob_start();?>'.st.'<?php $_tmp'.self::$prefix_number.'=ob_get_clean();?>';
$tmp = $this->compiler->appendCode('<?php ob_start();?>', st);
$this->compiler->prefix_code[] = $this->compiler->appendCode($tmp, '<?php $_tmp'.self::$prefix_number.'=ob_get_clean();?>');
res = '$_tmp'.self::$prefix_number;
}

File diff suppressed because it is too large Load Diff