Added support for the triple mustache! {{{foo}}} which means "don't escape HTML
in the replacement for this tag." This is already supported via {{&foo}} as
well, but we like to be thorough.
Also generate MustacheParseException when parsing (a subclass of
MustacheException) mostly for convenience in testing.
This commit is contained in:
@@ -112,6 +112,28 @@ public class MustacheTest
|
||||
test("foobar", "foo{{! nothing to see here}}bar", new Object());
|
||||
}
|
||||
|
||||
@Test public void testUnescapeHTML () {
|
||||
assertEquals("<b>", Mustache.compiler().escapeHTML(true).compile("{{&a}}").
|
||||
execute(context("a", "<b>")));
|
||||
assertEquals("<b>", Mustache.compiler().escapeHTML(true).compile("{{{a}}}").
|
||||
execute(context("a", "<b>")));
|
||||
// make sure these also work when escape HTML is off
|
||||
assertEquals("<b>", Mustache.compiler().escapeHTML(false).compile("{{&a}}").
|
||||
execute(context("a", "<b>")));
|
||||
assertEquals("<b>", Mustache.compiler().escapeHTML(false).compile("{{{a}}}").
|
||||
execute(context("a", "<b>")));
|
||||
}
|
||||
|
||||
@Test(expected = MustacheParseException.class)
|
||||
public void testDanglingTag () {
|
||||
Mustache.compiler().escapeHTML(true).compile("{{a").execute(context("a", "<b>"));
|
||||
}
|
||||
|
||||
@Test(expected = MustacheParseException.class)
|
||||
public void testInvalidUnescapeHTML () {
|
||||
Mustache.compiler().escapeHTML(true).compile("{{{a}}").execute(context("a", "<b>"));
|
||||
}
|
||||
|
||||
@Test public void testEscapeHTML () {
|
||||
assertEquals("<b>", Mustache.compiler().compile("{{a}}").
|
||||
execute(context("a", "<b>")));
|
||||
|
||||
Reference in New Issue
Block a user