From fe91be1fb1b184601de7404fcc187a5ac4f41cf8 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Fri, 26 Nov 2010 14:07:10 -0500 Subject: [PATCH] Pre-escape tag type constants (saves us from doing it each time the regex strings are prepared) --- Mustache.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Mustache.php b/Mustache.php index 19a72d6..fc7bd32 100644 --- a/Mustache.php +++ b/Mustache.php @@ -258,13 +258,13 @@ class Mustache { return $template; } - const SECTION_TYPES = '^#/'; + const SECTION_TYPES = '\^#\/'; protected function _prepareSectionRegEx($otag, $ctag) { return sprintf( '/(?:(?<=\\n)[ \\t]*)?%s(?[%s])(?.+?)%s\\n?/s', preg_quote($otag, '/'), - preg_quote(self::SECTION_TYPES, '/'), + self::SECTION_TYPES, preg_quote($ctag, '/') ); } @@ -437,13 +437,13 @@ class Mustache { return (isset($this->_throwsExceptions[$exception]) && $this->_throwsExceptions[$exception]); } - const TAG_TYPES = '#^/=!<>\\{&'; + const TAG_TYPES = '#\^\/=!<>\\{&'; protected function _prepareTagRegex($otag, $ctag) { return sprintf( '/(?(?<=\\n)[ \\t]*)?%s(?[%s]?)(?.+?)(?:\\2|})?%s(?:\\s*(?=\\n))?/s', preg_quote($otag, '/'), - preg_quote(self::TAG_TYPES, '/'), + self::TAG_TYPES, preg_quote($ctag, '/') ); }