Prechádzať zdrojové kódy

Merge branch 'patch-1' into dev

Justin Hileman 14 rokov pred
rodič
commit
11c3054f04
2 zmenil súbory, kde vykonal 10 pridanie a 10 odobranie
  1. 4 4
      Mustache.php
  2. 6 6
      test/MustacheTest.php

+ 4 - 4
Mustache.php

@@ -90,9 +90,9 @@ class Mustache {
 	 *         // opening and closing delimiters, as an array or a space-separated string
 	 *         'delimiters' => '<% %>',
 	 *
-	 *         // an array of pragmas to enable
+	 *         // an array of pragmas to enable/disable
 	 *         'pragmas' => array(
-	 *             Mustache::PRAGMA_UNESCAPED
+	 *             Mustache::PRAGMA_UNESCAPED => true
 	 *         ),
 	 *     );
 	 *
@@ -132,8 +132,8 @@ class Mustache {
 		}
 
 		if (isset($options['pragmas'])) {
-			foreach ($options['pragmas'] as $pragma_name) {
-				if (!in_array($pragma_name, $this->_pragmasImplemented)) {
+			foreach ($options['pragmas'] as $pragma_name => $pragma_value) {
+				if (!in_array($pragma_name, $this->_pragmasImplemented, true)) {
 					throw new MustacheException('Unknown pragma: ' . $pragma_name, MustacheException::UNKNOWN_PRAGMA);
 				}
 			}

+ 6 - 6
test/MustacheTest.php

@@ -94,21 +94,21 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
 				array(
 					'charset'    => 'UTF-8',
 					'delimiters' => '<< >>',
-					'pragmas'    => array(Mustache::PRAGMA_UNESCAPED)
+					'pragmas'    => array(Mustache::PRAGMA_UNESCAPED => true)
 				),
 				'UTF-8',
 				array('<<', '>>'),
-				array(Mustache::PRAGMA_UNESCAPED),
+				array(Mustache::PRAGMA_UNESCAPED => true),
 			),
 			array(
 				array(
 					'charset'    => 'cp866',
 					'delimiters' => array('[[[[', ']]]]'),
-					'pragmas'    => array(Mustache::PRAGMA_UNESCAPED)
+					'pragmas'    => array(Mustache::PRAGMA_UNESCAPED => true)
 				),
 				'cp866',
 				array('[[[[', ']]]]'),
-				array(Mustache::PRAGMA_UNESCAPED),
+				array(Mustache::PRAGMA_UNESCAPED => true),
 			),
 		);
 	}
@@ -117,7 +117,7 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
 	 * @expectedException MustacheException
 	 */
 	public function testConstructorInvalidPragmaOptionsThrowExceptions() {
-		$mustache = new Mustache(null, null, null, array('pragmas' => array('banana phone')));
+		$mustache = new Mustache(null, null, null, array('pragmas' => array('banana phone' => true)));
 	}
 
 	/**
@@ -195,7 +195,7 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
 		$this->assertEquals('Charlie Chaplin', $m->render(null, array('first_name' => 'Charlie', 'last_name' => 'Chaplin')));
 		$this->assertEquals('Zappa, Frank', $m->render('{{last_name}}, {{first_name}}', array('first_name' => 'Frank', 'last_name' => 'Zappa')));
 	}
-	
+
 	/**
 	 * @group interpolation
 	 * @dataProvider interpolationData