diff --git a/Mustache.php b/Mustache.php index 2b7551c..4fded45 100644 --- a/Mustache.php +++ b/Mustache.php @@ -385,7 +385,7 @@ class Mustache { $otag = preg_quote($this->_otag, '/'); $ctag = preg_quote($this->_ctag, '/'); - $this->_tagRegEx = '/' . $otag . "([#\^\/=!>\\{&])?(.+?)\\1?" . $ctag . "+/s"; + $this->_tagRegEx = '/' . $otag . "([#\^\/=!<>\\{&])?(.+?)\\1?" . $ctag . "+/s"; $html = ''; $matches = array(); @@ -442,6 +442,7 @@ class Mustache { return $this->_renderComment($tag_name); break; case '>': + case '<': return $this->_renderPartial($tag_name); break; case '{': @@ -469,7 +470,7 @@ class Mustache { * @return string */ protected function _renderEscaped($tag_name) { - return htmlentities($this->_getVariable($tag_name), null, $this->_charset); + return htmlentities($this->_getVariable($tag_name), ENT_COMPAT, $this->_charset); } /** @@ -521,7 +522,7 @@ class Mustache { $otag = preg_quote($this->_otag, '/'); $ctag = preg_quote($this->_ctag, '/'); - $this->_tagRegEx = '/' . $otag . "([#\^\/=!>\\{&])?(.+?)\\1?" . $ctag . "+/s"; + $this->_tagRegEx = '/' . $otag . "([#\^\/=!<>\\{&])?(.+?)\\1?" . $ctag . "+/s"; return ''; } @@ -608,7 +609,7 @@ class Mustache { } else if (isset($view->$tag_name)) { return $view->$tag_name; } - } else if (isset($view[$tag_name])) { + } else if (array_key_exists($tag_name, $view)) { return $view[$tag_name]; } } diff --git a/examples/escaped/Escaped.php b/examples/escaped/Escaped.php index e6605bc..2852196 100644 --- a/examples/escaped/Escaped.php +++ b/examples/escaped/Escaped.php @@ -1,5 +1,5 @@ Shark"; + public $title = '"Bear" > "Shark"'; } \ No newline at end of file diff --git a/examples/escaped/escaped.txt b/examples/escaped/escaped.txt index dcab18d..6ba3657 100644 --- a/examples/escaped/escaped.txt +++ b/examples/escaped/escaped.txt @@ -1 +1 @@ -