From f92509a872889f3be2dcb18275d234c8eea4e4cb Mon Sep 17 00:00:00 2001 From: Daniel Bruckner Date: Wed, 6 Mar 2013 12:46:36 -0800 Subject: [PATCH] fixes #28 --- src/main/java/com/samskivert/mustache/Mustache.java | 5 +++-- src/test/java/com/samskivert/mustache/MustacheTest.java | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/samskivert/mustache/Mustache.java b/src/main/java/com/samskivert/mustache/Mustache.java index 77cb784..15be24f 100644 --- a/src/main/java/com/samskivert/mustache/Mustache.java +++ b/src/main/java/com/samskivert/mustache/Mustache.java @@ -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; diff --git a/src/test/java/com/samskivert/mustache/MustacheTest.java b/src/test/java/com/samskivert/mustache/MustacheTest.java index ab5c1e5..f18343f 100644 --- a/src/test/java/com/samskivert/mustache/MustacheTest.java +++ b/src/test/java/com/samskivert/mustache/MustacheTest.java @@ -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);