Kaynağa Gözat

added test and known issue for dot notation/implicit iterator woes.

Justin Hileman 15 yıl önce
ebeveyn
işleme
2018449184
2 değiştirilmiş dosya ile 18 ekleme ve 0 silme
  1. 2 0
      README.markdown
  2. 16 0
      test/MustachePragmaImplicitIteratorTest.php

+ 2 - 0
README.markdown

@@ -85,6 +85,8 @@ Known Issues
    to all subsequent templates and partials rendered by this Mustache instance.
  * Sections don't respect delimiter changes -- `delimiters` example currently fails with an
    "unclosed section" exception.
+ * Dot notation and implicit iterators don't really play nice. A non-traversible local context is
+   passed to the section.
  * Test coverage is incomplete.
 
 

+ 16 - 0
test/MustachePragmaImplicitIteratorTest.php

@@ -36,4 +36,20 @@ class MustachePragmaImplicitIteratorTest extends PHPUnit_Framework_TestCase {
 		$this->assertEquals('foobarbaz', $m->render('{{%IMPLICIT-ITERATOR iterator=items}}{{#items}}{{items}}{{/items}}'));
 	}
 
+	public function testDotNotationContext() {
+		$m = new Mustache(null, array('items' => array(
+			array('index' => 1, 'name' => 'foo'),
+			array('index' => 2, 'name' => 'bar'),
+			array('index' => 3, 'name' => 'baz'),
+		)));
+
+		$this->assertEquals('foobarbaz', $m->render('{{%IMPLICIT-ITERATOR}}{{#items}}{{#.}}{{name}}{{/.}}{{/items}}'));
+
+		// skip the last two tests here, they just break...
+		$this->markTestSkipped('Implicit iterator not completely compatible with dot notation');
+
+		$this->assertEquals('123', $m->render('{{%IMPLICIT-ITERATOR iterator=i}}{{#items}}{{i.index}}{{/items}}'));
+		$this->assertEquals('foobarbaz', $m->render('{{%IMPLICIT-ITERATOR iterator=i}}{{#items}}{{i.name}}{{/items}}'));
+	}
+
 }