diff --git a/README.md b/README.md index 80d65e9..072adca 100644 --- a/README.md +++ b/README.md @@ -233,6 +233,29 @@ You can change the default HTML escaping behavior when obtaining a compiler: // result: // 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 -----------------