Let's escape HTML by default so as to avoid confusion.

This commit is contained in:
Michael Bayne
2010-10-21 21:03:52 +00:00
parent 5a5dd17296
commit 5042cc69fa
2 changed files with 6 additions and 5 deletions
@@ -57,11 +57,11 @@ public class Mustache
} }
/** /**
* Returns a compiler that <em>does not</em> escape HTML by default. * Returns a compiler that escapes HTML by default.
*/ */
public static Compiler compiler () public static Compiler compiler ()
{ {
return new Compiler(false); return new Compiler(true);
} }
/** /**
@@ -114,9 +114,10 @@ public class MustacheTest
} }
@Test public void testEscapeHTML () { @Test public void testEscapeHTML () {
assertEquals("<b>", Mustache.compiler().compile("{{a}}").execute(context("a", "<b>"))); assertEquals("&lt;b&gt;", Mustache.compiler().compile("{{a}}").
assertEquals("&lt;b&gt;", Mustache.compiler().escapeHTML(true). execute(context("a", "<b>")));
compile("{{a}}").execute(context("a", "<b>"))); assertEquals("<b>", Mustache.compiler().escapeHTML(false).compile("{{a}}").
execute(context("a", "<b>")));
} }
protected void test (String expected, String template, Object ctx) protected void test (String expected, String template, Object ctx)