Fixed dropped character on partial delimiter match.

This commit is contained in:
Michael Bayne
2010-10-21 21:13:09 +00:00
parent 5042cc69fa
commit 3bad793de9
2 changed files with 8 additions and 0 deletions
@@ -113,6 +113,7 @@ public class Mustache
} else {
text.append(start1);
if (c != start1) {
text.append(c);
state = TEXT;
}
}
@@ -146,6 +147,7 @@ public class Mustache
} else {
text.append(end1);
if (c != end1) {
text.append(c);
state = TAG;
}
}
@@ -120,6 +120,12 @@ public class MustacheTest
execute(context("a", "<b>")));
}
@Test public void testPartialDelimiterMatch () {
assertEquals("{bob}", Mustache.compiler().compile("{bob}").execute(context()));
assertEquals("bar", Mustache.compiler().compile("{{bob}bob}}").execute(
context("bob}bob", "bar")));
}
protected void test (String expected, String template, Object ctx)
{
assertEquals(expected, Mustache.compiler().compile(template).execute(ctx));