From c849d351f9a9ec730143629a02ba79a7ae6b6213 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Mon, 22 Mar 2010 19:15:46 -0400 Subject: [PATCH] Split section exceptions, variable exceptions and partial exceptions into distinct configuration options. --- Mustache.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Mustache.php b/Mustache.php index 36b341e..7542f65 100644 --- a/Mustache.php +++ b/Mustache.php @@ -18,7 +18,9 @@ class Mustache { public $ctag = '}}'; // Should this Mustache throw exceptions when it finds unexpected tags? - protected $throwExceptions = false; + protected $throwSectionExceptions = true; + protected $throwPartialExceptions = false; + protected $throwVariableExceptions = false; protected $tagRegEx; @@ -170,14 +172,14 @@ class Mustache { protected function renderTag($modifier, $tag_name, &$context) { switch ($modifier) { case '#': - if ($this->throwExceptions) { + if ($this->throwSectionExceptions) { throw new MustacheException('Unclosed section: ' . $tag_name, MustacheException::UNCLOSED_SECTION); } else { return ''; } break; case '/': - if ($this->throwExceptions) { + if ($this->throwSectionExceptions) { throw new MustacheException('Unexpected close section: ' . $tag_name, MustacheException::UNEXPECTED_CLOSE_SECTION); } else { return ''; @@ -321,7 +323,7 @@ class Mustache { } } - if ($this->throwExceptions) { + if ($this->throwVariableExceptions) { throw new MustacheException("Unknown variable: " . $tag_name, MustacheException::UNKNOWN_VARIABLE); } else { return ''; @@ -342,7 +344,7 @@ class Mustache { return $this->partials[$tag_name]; } - if ($this->throwExceptions) { + if ($this->throwPartialExceptions) { throw new MustacheException('Unknown partial: ' . $tag_name, MustacheException::UNKNOWN_PARTIAL); } else { return '';