diff --git a/NEWS b/NEWS index a8fe98d7..fa398543 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ + - added optional assign-attribute to {capture}-tag (messju) - added $cacheable-parameter to register_compiler_function() (messju) - added $cacheable-parameter with default=true to register_function() and register_block() (messju) diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 8a9d2578..a81fa0a0 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -1110,11 +1110,19 @@ class Smarty_Compiler extends Smarty { else $buffer = "'default'"; + if (isset($attrs['assign'])) + $assign = $attrs['assign']; + else + $assign = null; $output = ""; - $this->_capture_stack[] = $buffer; + $this->_capture_stack[] = array($buffer, $assign); } else { - $buffer = array_pop($this->_capture_stack); - $output = "_smarty_vars['capture'][$buffer] = ob_get_contents(); ob_end_clean(); ?>"; + list($buffer, $assign) = array_pop($this->_capture_stack); + $output = "_smarty_vars['capture'][$buffer] = ob_get_contents(); "; + if (isset($assign)) { + $output .= " \$this->assign($assign, ob_get_contents());"; + } + $output .= "ob_end_clean(); ?>"; } return $output;