Work in progress. Fixing double-rendering of sections, mustache injection, etc.
This commit is contained in:
+7
-17
@@ -211,20 +211,10 @@ class Mustache {
|
|||||||
* @return string Rendered Mustache template.
|
* @return string Rendered Mustache template.
|
||||||
*/
|
*/
|
||||||
protected function _renderTemplate($template) {
|
protected function _renderTemplate($template) {
|
||||||
$template = $this->_renderSections($template);
|
if ($section = $this->_findSection($template)) {
|
||||||
return $this->_renderTags($template);
|
list($section, $offset, $type, $tag_name, $content) = $section;
|
||||||
}
|
$before = substr($template, 0, $offset);
|
||||||
|
$after = substr($template, $offset + strlen($section));
|
||||||
/**
|
|
||||||
* Render boolean, enumerable and inverted sections.
|
|
||||||
*
|
|
||||||
* @access protected
|
|
||||||
* @param string $template
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function _renderSections($template) {
|
|
||||||
while ($section_data = $this->_findSection($template)) {
|
|
||||||
list($section, $offset, $type, $tag_name, $content) = $section_data;
|
|
||||||
|
|
||||||
$replace = '';
|
$replace = '';
|
||||||
$val = $this->_getVariable($tag_name);
|
$val = $this->_getVariable($tag_name);
|
||||||
@@ -256,10 +246,10 @@ class Mustache {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$template = substr_replace($template, $replace, $offset, strlen($section));
|
return $this->_renderTags($before) . $replace . $this->_renderTemplate($after);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $template;
|
return $this->_renderTags($template);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -856,4 +846,4 @@ class MustacheException extends Exception {
|
|||||||
// which can't be handled by this Mustache instance.
|
// which can't be handled by this Mustache instance.
|
||||||
const UNKNOWN_PRAGMA = 4;
|
const UNKNOWN_PRAGMA = 4;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user