mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- new feature The named capture buffers can now be accessed also as array
See NEWS_FEATURES.txt https://github.com/smarty-php/smarty/issues/366
This commit is contained in:
@@ -2,7 +2,20 @@
|
||||
|
||||
This file contains a brief description of new features which have been added to Smarty 3.1
|
||||
|
||||
Smarty 3.1.31
|
||||
Smarty 3.1.32
|
||||
The capture buffers can now be accessed as array
|
||||
================================================
|
||||
{capture name='foo'}
|
||||
bah
|
||||
{\capture}
|
||||
{capture name='buh'}
|
||||
blar
|
||||
{\capture}
|
||||
{foreach $smarty.capture as $name => $buffer}
|
||||
....
|
||||
{/foreach}
|
||||
|
||||
Smarty 3.1.31
|
||||
New tags for inheritance parent and child
|
||||
=========================================
|
||||
{block_parent} == {$smarty.block.parent}
|
||||
|
@@ -2,6 +2,8 @@
|
||||
19.5.2017
|
||||
- change properties $accessMap and $obsoleteProperties from private to protected
|
||||
https://github.com/smarty-php/smarty/issues/351
|
||||
- improvement The named capture buffers can now be accessed also as array
|
||||
See NEWS_FEATURES.txt https://github.com/smarty-php/smarty/issues/366
|
||||
|
||||
24.4.2017
|
||||
- fix spelling https://github.com/smarty-php/smarty/commit/e3eda8a5f5653d8abb960eb1bc47e3eca679b1b4#commitcomment-21803095
|
||||
|
@@ -45,11 +45,11 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
|
||||
public static function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = null)
|
||||
{
|
||||
$tag = trim($parameter[ 0 ], '"\'');
|
||||
$name = isset($parameter[ 1 ]) ? $compiler->getId($parameter[ 1 ]) : false;
|
||||
$name = isset($parameter[ 1 ]) ? $compiler->getId($parameter[ 1 ]) : null;
|
||||
if (!$name) {
|
||||
$compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", null, true);
|
||||
//$compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", null, true);
|
||||
}
|
||||
return "\$_smarty_tpl->smarty->ext->_capture->getBuffer(\$_smarty_tpl, '{$name}')";
|
||||
return '$_smarty_tpl->smarty->ext->_capture->getBuffer($_smarty_tpl'.(isset($name)?"'{$name}')":')');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -64,7 +64,9 @@ class Smarty_Internal_Runtime_Capture
|
||||
if (!$this->isRegistered) {
|
||||
$this->register($_template);
|
||||
}
|
||||
$this->captureStack[] = array($buffer, $assign, $append);
|
||||
$this->captureStack[] = array($buffer,
|
||||
$assign,
|
||||
$append);
|
||||
$this->captureCount ++;
|
||||
ob_start();
|
||||
}
|
||||
@@ -76,8 +78,10 @@ class Smarty_Internal_Runtime_Capture
|
||||
*/
|
||||
private function register(Smarty_Internal_Template $_template)
|
||||
{
|
||||
$_template->startRenderCallbacks[] = array($this, 'startRender');
|
||||
$_template->endRenderCallbacks[] = array($this, 'endRender');
|
||||
$_template->startRenderCallbacks[] = array($this,
|
||||
'startRender');
|
||||
$_template->endRenderCallbacks[] = array($this,
|
||||
'endRender');
|
||||
$this->startRender($_template);
|
||||
$this->isRegistered = true;
|
||||
}
|
||||
@@ -130,16 +134,20 @@ class Smarty_Internal_Runtime_Capture
|
||||
}
|
||||
|
||||
/**
|
||||
* Return content of named capture buffer
|
||||
* Return content of named capture buffer by key or as array
|
||||
*
|
||||
* @param \Smarty_Internal_Template $_template
|
||||
* @param $name
|
||||
* @param string|null $name
|
||||
*
|
||||
* @return null
|
||||
* @return string|string[]|null
|
||||
*/
|
||||
public function getBuffer(Smarty_Internal_Template $_template, $name)
|
||||
public function getBuffer(Smarty_Internal_Template $_template, $name = null)
|
||||
{
|
||||
return isset($this->namedBuffer[ $name ]) ? $this->namedBuffer[ $name ] : null;
|
||||
if (isset($name)) {
|
||||
return isset($this->namedBuffer[ $name ]) ? $this->namedBuffer[ $name ] : null;
|
||||
} else {
|
||||
return $this->namedBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user