Browse files

Tested comments

- Tested (and fixed) comment lexing and (lack of) rendering
  • Loading branch information...
1 parent 95ec004 commit 4ac46469a8149759e7a21ee4fd58ed7207cf12df @weierophinney weierophinney committed Aug 31, 2010
View
1 .project
@@ -52,6 +52,7 @@ mustache=/home/matthew/git/phly_mustache CD=. filter="*.php *.html *.xml *.txt"
partial-template.mustache
renders-file-templates.mustache
template-with-aliased-partial.mustache
+ template-with-comments.mustache
template-with-conditional.mustache
template-with-dereferencing.mustache
template-with-enumerable.mustache
View
1 TODO
@@ -1,6 +1,5 @@
API documentation
Tests
- for comments
for delimiters
for ensuring pragmas, delimiters are section-specific
Delimiters should not extend to partials
View
1 library/Phly/Mustache/Lexer.php
@@ -169,6 +169,7 @@ public function compile($string)
// Comment
// Create token
$token = array(self::TOKEN_COMMENT, ltrim($tagData, '!'));
+ $state = self::STATE_CONTENT;
++$i;
break;
case '>':
View
13 tests/PhlyTest/Mustache/MustacheTest.php
@@ -339,4 +339,17 @@ public function testAllowsSettingAlternateTemplateSuffix()
$test = $this->mustache->render('alternate-suffix', array());
$this->assertContains('alternate template suffix', $test);
}
+
+ public function testStripsCommentsFromRenderedOutput()
+ {
+ $test = $this->mustache->render('template-with-comments', array());
+ $expected =<<<EOT
+First line
+Second line
+
+Third line
+
+EOT;
+ $this->assertEquals($expected, $test);
+ }
}
View
7 tests/PhlyTest/Mustache/templates/template-with-comments.mustache
@@ -0,0 +1,7 @@
+First line {{! this is a comment}}
+Second line
+{{! this is
+a
+multiline
+comment}}
+Third line

0 comments on commit 4ac4646

Please sign in to comment.