mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-02 21:31:48 +01:00
parser: add support for template prefix and postfix code
This commit is contained in:
@@ -51,6 +51,32 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Append array to subtree
|
||||
*
|
||||
* @param \Smarty_Internal_Templateparser $parser
|
||||
* @param \Smarty_Internal_ParseTree[] $array
|
||||
*/
|
||||
public function append_array(Smarty_Internal_Templateparser $parser, $array = array())
|
||||
{
|
||||
if (!empty($array)) {
|
||||
$this->subtrees = array_merge($this->subtrees, (array) $array);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepend array to subtree
|
||||
*
|
||||
* @param \Smarty_Internal_Templateparser $parser
|
||||
* @param \Smarty_Internal_ParseTree[] $array
|
||||
*/
|
||||
public function prepend_array(Smarty_Internal_Templateparser $parser, $array = array())
|
||||
{
|
||||
if (!empty($array)) {
|
||||
$this->subtrees = array_merge((array) $array, $this->subtrees);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize and merge subtree buffers together
|
||||
*
|
||||
@@ -75,7 +101,8 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
|
||||
if ($subtree == '') {
|
||||
continue;
|
||||
}
|
||||
$code .= preg_replace('/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/', "<?php echo '\$1'; ?>\n", $subtree);
|
||||
$code .= preg_replace('/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/', "<?php echo '\$1'; ?>\n",
|
||||
$subtree);
|
||||
continue;
|
||||
}
|
||||
if ($this->subtrees[$key] instanceof Smarty_Internal_ParseTree_Tag) {
|
||||
|
||||
Reference in New Issue
Block a user