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

This commit is contained in:
Uwe Tews
2015-05-13 02:09:00 +02:00
parent 2b858212b7
commit 3240b5a596

View File

@@ -854,6 +854,24 @@ abstract class Smarty_Internal_TemplateCompilerBase
return false;
}
/**
* Append code segments and remove unneeded ?> <?php transitions
*
* @param string $left
* @param string $right
*
* @return string
*/
public function appendCode($left, $right) {
if ( preg_match('/\s*\?>\s*$/', $left) && preg_match('/^\s*<\?php\s+/', $right)) {
$left = preg_replace('/\s*\?>\s*$/', "\n", $left);
$left .= preg_replace('/^\s*<\?php\s+/', '', $right);
} else {
$left .= $right;
}
return $left;
}
/**
* Inject inline code for nocache template sections
* This method gets the content of each template element from the parser.