mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-09 12:54:26 +02:00
- update on append and prepend attribute at {block} tag
This commit is contained in:
@@ -23,7 +23,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
$this->required_attributes = array('name');
|
||||
$this->optional_attributes = array('assign','append','prepend');
|
||||
$this->optional_attributes = array('assign');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
$save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code);
|
||||
|
@@ -34,9 +34,9 @@ class Smarty_Internal_Compile_BlockClose extends Smarty_Internal_CompileBase {
|
||||
$this->compiler->trigger_template_error('mismatching name attributes "' . $saved_data[0]['name'] . '" and "' . $_attr['name'] . '"');
|
||||
}
|
||||
$_name = trim($saved_data[0]['name'], "'");
|
||||
if (isset($saved_data[0]['append'])) {
|
||||
if ($compiler->template->block_data[$_name]['mode'] == 'prepend') {
|
||||
$_output = $compiler->template->block_data[$_name]['compiled'].$compiler->template->extracted_compiled_code;
|
||||
} elseif (isset($saved_data[0]['prepend'])) {
|
||||
} elseif ($compiler->template->block_data[$_name]['mode'] == 'append') {
|
||||
$_output = $compiler->template->extracted_compiled_code.$compiler->template->block_data[$_name]['compiled'];
|
||||
} elseif (!empty($compiler->template->block_data[$_name])) {
|
||||
$_output = $compiler->template->block_data[$_name]['compiled'];
|
||||
|
@@ -53,16 +53,25 @@ class Smarty_Internal_Compile_Extend extends Smarty_Internal_CompileBase {
|
||||
$tpl->suppressHeader = false;
|
||||
$_name = trim($_match[3], "\"'");
|
||||
|
||||
if (preg_match('/(.?)(append=true)(.*)/', $matches[2], $_match) != 0) {
|
||||
if ($this->compiler->template->block_data[$_name]['mode'] == 'prepend') {
|
||||
$this->compiler->template->block_data[$_name]['compiled'] .= $compiled_content;
|
||||
$this->compiler->template->block_data[$_name]['source'] .= $matches[3];
|
||||
} elseif (preg_match('/(.?)(prepend=true)(.*)/', $matches[2], $_match) != 0) {
|
||||
} elseif ($this->compiler->template->block_data[$_name]['mode'] == 'append') {
|
||||
$this->compiler->template->block_data[$_name]['compiled'] = $compiled_content . $this->compiler->template->block_data[$_name]['compiled'];
|
||||
$this->compiler->template->block_data[$_name]['source'] = $matches[3] . $this->compiler->template->block_data[$_name]['source'];
|
||||
} elseif (!isset($this->compiler->template->block_data[$_name])) {
|
||||
$this->compiler->template->block_data[$_name]['compiled'] = $compiled_content;
|
||||
$this->compiler->template->block_data[$_name]['source'] = $matches[3];
|
||||
}
|
||||
if ($this->compiler->template->block_data[$_name]['mode'] != 'replace') {
|
||||
if (preg_match('/(.?)(append=true)(.*)/', $matches[2], $_match) != 0) {
|
||||
$this->compiler->template->block_data[$_name]['mode'] = 'append';
|
||||
} elseif (preg_match('/(.?)(prepend=true)(.*)/', $matches[2], $_match) != 0) {
|
||||
$this->compiler->template->block_data[$_name]['mode'] = 'prepend';
|
||||
} else {
|
||||
$this->compiler->template->block_data[$_name]['mode'] = 'replace';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user