add append feature to capture

This commit is contained in:
mohrt
2007-08-01 13:34:39 +00:00
parent 42d646836c
commit 3cb64d6a44
2 changed files with 10 additions and 11 deletions

1
NEWS
View File

@@ -1,3 +1,4 @@
- add append feature to {capture} (jablko, monte)
- fix when (un)registering filters with the same method name but different class - fix when (un)registering filters with the same method name but different class
name (danilo) name (danilo)
- fix calling registered objects' methods with an empty argument list - fix calling registered objects' methods with an empty argument list

View File

@@ -1222,23 +1222,21 @@ class Smarty_Compiler extends Smarty {
$attrs = $this->_parse_attrs($tag_args); $attrs = $this->_parse_attrs($tag_args);
if ($start) { if ($start) {
if (isset($attrs['name'])) $buffer = isset($attrs['name']) ? $attrs['name'] : "'default'";
$buffer = $attrs['name']; $assign = isset($attrs['assign']) ? $attrs['assign'] : null;
else $append = isset($attrs['append']) ? $attrs['append'] : null;
$buffer = "'default'";
if (isset($attrs['assign']))
$assign = $attrs['assign'];
else
$assign = null;
$output = "<?php ob_start(); ?>"; $output = "<?php ob_start(); ?>";
$this->_capture_stack[] = array($buffer, $assign); $this->_capture_stack[] = array($buffer, $assign, $append);
} else { } else {
list($buffer, $assign) = array_pop($this->_capture_stack); list($buffer, $assign, $append) = array_pop($this->_capture_stack);
$output = "<?php \$this->_smarty_vars['capture'][$buffer] = ob_get_contents(); "; $output = "<?php \$this->_smarty_vars['capture'][$buffer] = ob_get_contents(); ";
if (isset($assign)) { if (isset($assign)) {
$output .= " \$this->assign($assign, ob_get_contents());"; $output .= " \$this->assign($assign, ob_get_contents());";
} }
if (isset($append)) {
$output .= " \$this->append($append, ob_get_contents());";
}
$output .= "ob_end_clean(); ?>"; $output .= "ob_end_clean(); ?>";
} }