Browse Source

Use the _throwsExceptions(MustacheException::UNKNOWN_PRAGMA) config
properly

Chris Czub 14 năm trước cách đây
mục cha
commit
1c2e9a22d3
1 tập tin đã thay đổi với 8 bổ sung2 xóa
  1. 8 2
      Mustache.php

+ 8 - 2
Mustache.php

@@ -403,7 +403,10 @@ class Mustache {
 		$options_string = $matches['options_string'];
 
 		if (!in_array($pragma_name, $this->_pragmasImplemented)) {
-			throw new MustacheException('Unknown pragma: ' . $pragma_name, MustacheException::UNKNOWN_PRAGMA);
+			if($this->_throwsException(MustacheException::UNKNOWN_PRAGMA))
+				throw new MustacheException('Unknown pragma: ' . $pragma_name, MustacheException::UNKNOWN_PRAGMA);
+			else
+				return '';
 		}
 
 		$options = array();
@@ -448,7 +451,10 @@ class Mustache {
 	 */
 	protected function _getPragmaOptions($pragma_name) {
 		if (!$this->_hasPragma($pragma_name)) {
-			throw new MustacheException('Unknown pragma: ' . $pragma_name, MustacheException::UNKNOWN_PRAGMA);
+			if($this->_throwsException(MustacheException::UNKNOWN_PRAGMA))
+				throw new MustacheException('Unknown pragma: ' . $pragma_name, MustacheException::UNKNOWN_PRAGMA);
+			else
+				return array();
 		}
 
 		return (is_array($this->_localPragmas[$pragma_name])) ? $this->_localPragmas[$pragma_name] : array();