added optional assign-attribute to {capture}-tag

This commit is contained in:
messju
2003-06-19 10:42:59 +00:00
parent 5a803ca612
commit 2f1e635f21
2 changed files with 12 additions and 3 deletions

1
NEWS
View File

@@ -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)

View File

@@ -1110,11 +1110,19 @@ class Smarty_Compiler extends Smarty {
else
$buffer = "'default'";
if (isset($attrs['assign']))
$assign = $attrs['assign'];
else
$assign = null;
$output = "<?php ob_start(); ?>";
$this->_capture_stack[] = $buffer;
$this->_capture_stack[] = array($buffer, $assign);
} else {
$buffer = array_pop($this->_capture_stack);
$output = "<?php \$this->_smarty_vars['capture'][$buffer] = ob_get_contents(); ob_end_clean(); ?>";
list($buffer, $assign) = array_pop($this->_capture_stack);
$output = "<?php \$this->_smarty_vars['capture'][$buffer] = ob_get_contents(); ";
if (isset($assign)) {
$output .= " \$this->assign($assign, ob_get_contents());";
}
$output .= "ob_end_clean(); ?>";
}
return $output;