Class EscapeChar

  • All Implemented Interfaces:
    com.samskivert.mustache.Mustache.Lambda

    public class EscapeChar
    extends Object
    implements com.samskivert.mustache.Mustache.Lambda
    Escapes the desired character if not escaped already, e.g. $ => \$.

    Register: additionalProperties.put("escapeDollar", new EscapeChar("(?<!\\\\)\\$", "\\\\\\$"));

    Use: {{#lambda.escapeDollar}}{{name}}{{/lambda.escapeDollar}}

    • Constructor Detail

      • EscapeChar

        public EscapeChar​(String matchPattern,
                          String replacement)
        Constructs a new instance of EscapeChar, with the desired character to escape
        Parameters:
        matchPattern - the character to escape
        replacement - the escaped character
    • Method Detail

      • execute

        public void execute​(com.samskivert.mustache.Template.Fragment fragment,
                            Writer writer)
                     throws IOException
        Specified by:
        execute in interface com.samskivert.mustache.Mustache.Lambda
        Throws:
        IOException