Simplified tag RegEx. Fixed bug preventing section modifiers inside comments.
This commit is contained in:
+3
-2
@@ -177,7 +177,7 @@ class Mustache {
|
|||||||
|
|
||||||
$otag = $this->prepareRegEx($this->otag);
|
$otag = $this->prepareRegEx($this->otag);
|
||||||
$ctag = $this->prepareRegEx($this->ctag);
|
$ctag = $this->prepareRegEx($this->ctag);
|
||||||
$this->tagRegEx = '/' . $otag . "(#|\/|=|!|>|\\{|&)?([^\/#]+?)\\1?" . $ctag . "+/";
|
$this->tagRegEx = '/' . $otag . "([#\^\/=!>\\{&])?(.+?)\\1?" . $ctag . "+/";
|
||||||
$html = '';
|
$html = '';
|
||||||
$matches = array();
|
$matches = array();
|
||||||
while (preg_match($this->tagRegEx, $template, $matches, PREG_OFFSET_CAPTURE)) {
|
while (preg_match($this->tagRegEx, $template, $matches, PREG_OFFSET_CAPTURE)) {
|
||||||
@@ -210,6 +210,7 @@ class Mustache {
|
|||||||
protected function renderTag($modifier, $tag_name, &$context) {
|
protected function renderTag($modifier, $tag_name, &$context) {
|
||||||
switch ($modifier) {
|
switch ($modifier) {
|
||||||
case '#':
|
case '#':
|
||||||
|
case '^':
|
||||||
if ($this->throwSectionExceptions) {
|
if ($this->throwSectionExceptions) {
|
||||||
throw new MustacheException('Unclosed section: ' . $tag_name, MustacheException::UNCLOSED_SECTION);
|
throw new MustacheException('Unclosed section: ' . $tag_name, MustacheException::UNCLOSED_SECTION);
|
||||||
} else {
|
} else {
|
||||||
@@ -310,7 +311,7 @@ class Mustache {
|
|||||||
|
|
||||||
$otag = $this->prepareRegEx($this->otag);
|
$otag = $this->prepareRegEx($this->otag);
|
||||||
$ctag = $this->prepareRegEx($this->ctag);
|
$ctag = $this->prepareRegEx($this->ctag);
|
||||||
$this->tagRegEx = '/' . $otag . "(#|\/|=|!|>|\\{|&)?([^\/#\^]+?)\\1?" . $ctag . "+/";
|
$this->tagRegEx = '/' . $otag . "([#\^\/=!>\\{&])?(.+?)\\1?" . $ctag . "+/";
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<h1>{{title}}{{! just something interesting... or not... }}</h1>
|
<h1>{{title}}{{! just something interesting... #or ^not... }}</h1>
|
||||||
Reference in New Issue
Block a user