README describes user-extensible escaping rules (not just HTML or no escaping)
This commit is contained in:
@@ -233,6 +233,29 @@ You can change the default HTML escaping behavior when obtaining a compiler:
|
||||
// result: <bar>
|
||||
// not: <bar>
|
||||
|
||||
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
|
||||
-----------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user