Skip to content

Commit

Permalink
Pre-escape tag type constants (saves us from doing it each time the r…
Browse files Browse the repository at this point in the history
…egex strings are prepared)
  • Loading branch information
bobthecow committed Nov 26, 2010
1 parent 2b8e2f6 commit fe91be1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Mustache.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ protected function _renderSections($template) {
return $template;
}

const SECTION_TYPES = '^#/';
const SECTION_TYPES = '\^#\/';

protected function _prepareSectionRegEx($otag, $ctag) {
return sprintf(
'/(?:(?<=\\n)[ \\t]*)?%s(?<type>[%s])(?<tag_name>.+?)%s\\n?/s',
preg_quote($otag, '/'),
preg_quote(self::SECTION_TYPES, '/'),
self::SECTION_TYPES,
preg_quote($ctag, '/')
);
}
Expand Down Expand Up @@ -437,13 +437,13 @@ protected function _throwsException($exception) {
return (isset($this->_throwsExceptions[$exception]) && $this->_throwsExceptions[$exception]);
}

const TAG_TYPES = '#^/=!<>\\{&';
const TAG_TYPES = '#\^\/=!<>\\{&';
protected function _prepareTagRegex($otag, $ctag) {
return sprintf(
'/(?<whitespace>(?<=\\n)[ \\t]*)?%s(?<type>[%s]?)(?<tag_name>.+?)(?:\\2|})?%s(?:\\s*(?=\\n))?/s',
preg_quote($otag, '/'),
preg_quote(self::TAG_TYPES, '/'),
self::TAG_TYPES,
preg_quote($ctag, '/')
);
}
Expand Down

0 comments on commit fe91be1

Please sign in to comment.