Pre-escape tag type constants (saves us from doing it each time the regex strings are prepared)
This commit is contained in:
+4
-4
@@ -258,13 +258,13 @@ class Mustache {
|
|||||||
return $template;
|
return $template;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SECTION_TYPES = '^#/';
|
const SECTION_TYPES = '\^#\/';
|
||||||
|
|
||||||
protected function _prepareSectionRegEx($otag, $ctag) {
|
protected function _prepareSectionRegEx($otag, $ctag) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'/(?:(?<=\\n)[ \\t]*)?%s(?<type>[%s])(?<tag_name>.+?)%s\\n?/s',
|
'/(?:(?<=\\n)[ \\t]*)?%s(?<type>[%s])(?<tag_name>.+?)%s\\n?/s',
|
||||||
preg_quote($otag, '/'),
|
preg_quote($otag, '/'),
|
||||||
preg_quote(self::SECTION_TYPES, '/'),
|
self::SECTION_TYPES,
|
||||||
preg_quote($ctag, '/')
|
preg_quote($ctag, '/')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -437,13 +437,13 @@ class Mustache {
|
|||||||
return (isset($this->_throwsExceptions[$exception]) && $this->_throwsExceptions[$exception]);
|
return (isset($this->_throwsExceptions[$exception]) && $this->_throwsExceptions[$exception]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TAG_TYPES = '#^/=!<>\\{&';
|
const TAG_TYPES = '#\^\/=!<>\\{&';
|
||||||
|
|
||||||
protected function _prepareTagRegex($otag, $ctag) {
|
protected function _prepareTagRegex($otag, $ctag) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'/(?<whitespace>(?<=\\n)[ \\t]*)?%s(?<type>[%s]?)(?<tag_name>.+?)(?:\\2|})?%s(?:\\s*(?=\\n))?/s',
|
'/(?<whitespace>(?<=\\n)[ \\t]*)?%s(?<type>[%s]?)(?<tag_name>.+?)(?:\\2|})?%s(?:\\s*(?=\\n))?/s',
|
||||||
preg_quote($otag, '/'),
|
preg_quote($otag, '/'),
|
||||||
preg_quote(self::TAG_TYPES, '/'),
|
self::TAG_TYPES,
|
||||||
preg_quote($ctag, '/')
|
preg_quote($ctag, '/')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user