Fix the last couple of regressions with section rendering.
This commit is contained in:
+8
-10
@@ -214,13 +214,13 @@ class Mustache {
|
|||||||
if ($section = $this->_findSection($template)) {
|
if ($section = $this->_findSection($template)) {
|
||||||
list($before, $type, $tag_name, $content, $after) = $section;
|
list($before, $type, $tag_name, $content, $after) = $section;
|
||||||
|
|
||||||
$replace = '';
|
$renderedContent = '';
|
||||||
$val = $this->_getVariable($tag_name);
|
$val = $this->_getVariable($tag_name);
|
||||||
switch($type) {
|
switch($type) {
|
||||||
// inverted section
|
// inverted section
|
||||||
case '^':
|
case '^':
|
||||||
if (empty($val)) {
|
if (empty($val)) {
|
||||||
$replace .= $content;
|
$renderedContent = $this->_renderTemplate($content);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -229,22 +229,22 @@ class Mustache {
|
|||||||
if ($this->_varIsIterable($val)) {
|
if ($this->_varIsIterable($val)) {
|
||||||
foreach ($val as $local_context) {
|
foreach ($val as $local_context) {
|
||||||
$this->_pushContext($local_context);
|
$this->_pushContext($local_context);
|
||||||
$replace .= $this->_renderTemplate($content);
|
$renderedContent .= $this->_renderTemplate($content);
|
||||||
$this->_popContext();
|
$this->_popContext();
|
||||||
}
|
}
|
||||||
} else if ($val) {
|
} else if ($val) {
|
||||||
if (is_array($val) || is_object($val)) {
|
if (is_array($val) || is_object($val)) {
|
||||||
$this->_pushContext($val);
|
$this->_pushContext($val);
|
||||||
$replace .= $this->_renderTemplate($content);
|
$renderedContent = $this->_renderTemplate($content);
|
||||||
$this->_popContext();
|
$this->_popContext();
|
||||||
} else {
|
} else {
|
||||||
$replace .= $content;
|
$renderedContent = $this->_renderTemplate($content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_renderTags($before) . $replace . $this->_renderTemplate($after);
|
return $this->_renderTags($before) . $renderedContent . $this->_renderTemplate($after);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_renderTags($template);
|
return $this->_renderTags($template);
|
||||||
@@ -268,9 +268,7 @@ class Mustache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract a section from $template.
|
* Extract the first section from $template.
|
||||||
*
|
|
||||||
* This is a helper function to find sections needed by _renderSections.
|
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string $template
|
* @param string $template
|
||||||
@@ -566,7 +564,7 @@ class Mustache {
|
|||||||
case '#':
|
case '#':
|
||||||
case '^':
|
case '^':
|
||||||
case '/':
|
case '/':
|
||||||
// remove any leftovers from _renderSections
|
// remove any leftover section tags
|
||||||
return $leading . $trailing;
|
return $leading . $trailing;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user