Skip to content

Commit

Permalink
Tested comments
Browse files Browse the repository at this point in the history
- Tested (and fixed) comment lexing and (lack of) rendering
  • Loading branch information
weierophinney committed Aug 31, 2010
1 parent 95ec004 commit 4ac4646
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions .project
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion 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
Expand Down
1 change: 1 addition & 0 deletions library/Phly/Mustache/Lexer.php
Expand Up @@ -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 '>':
Expand Down
13 changes: 13 additions & 0 deletions tests/PhlyTest/Mustache/MustacheTest.php
Expand Up @@ -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);
}
}
@@ -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.