Let's escape HTML by default so as to avoid confusion.
This commit is contained in:
@@ -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("<b>", Mustache.compiler().compile("{{a}}").
|
||||||
assertEquals("<b>", 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)
|
||||||
|
|||||||
Reference in New Issue
Block a user