Merge pull request #29 from bruckner/master

Fixes issue 28, comments containing '}' parsed as text
This commit is contained in:
Michael Bayne
2013-03-06 12:59:46 -08:00
2 changed files with 7 additions and 2 deletions
@@ -335,10 +335,11 @@ public class Mustache
parseChar(NO_CHAR);
}
} else if (c == delims.start1 && text.length() > 0) {
} else if (c == delims.start1 && text.length() > 0 && text.charAt(0) != '!') {
// if we've already matched some tag characters and we see a new start tag
// character (e.g. "{{foo {" but not "{{{"), treat the already matched text as
// plain text and start matching a new tag from this point
// plain text and start matching a new tag from this point, unless we're in
// a comment tag.
restoreStartTag(text, delims);
accum.addTextSegment(text);
tagStartColumn = column;
@@ -169,6 +169,10 @@ public class MustacheTest
test("foobar", "foo{{! nothing to see here}}bar", new Object());
}
@Test public void testCommentWithFunnyChars() {
test("foobar", "foo{{! {baz\n }}bar", new Object());
}
@Test(expected=UnsupportedOperationException.class)
public void testPartialUseWhenUnconfigured () {
test(null, "{{>foo}}", null);