README describes user-extensible escaping rules (not just HTML or no escaping)

This commit is contained in:
Nat Pryce
2013-07-22 22:45:28 +01:00
parent 4ae290fdaa
commit 30907579eb
+23
View File
@@ -233,6 +233,29 @@ You can change the default HTML escaping behavior when obtaining a compiler:
// result: <bar>
// not: &lt;bar&gt;
User-defined escaping rules
---------------------------
You can change the escaping behavior when obtaining a compiler, to support file formats other than HTML and plain text.
Implement the Escaping interface. If you only need to replace fixed strings in the text, you can subclass SimpleEscaping:
public class StrangeFormatEscaping extends SimpleEscaping {
public StrangeFormatEscaping() {
super(new String[][] {
{"[", "[["},
{"]", "]]"}
});
}
Pass an instance of your Escaping implementation when obtaining a compiler:
Mustache.compiler().escape(new StrangeFormatEscaping()).compile("{{foo}}").execute(new Object() {
String foo = "[bar]";
});
// result: [[bar]]
Special variables
-----------------