@Override public String escape(String text) { // Fix included as suggested by akkie in #6393 // The given text is a reserved word which is escaped by enclosing it with grave accents. If we would // escape that with the default Mustache `HTML` escaper, then the escaper would also escape our grave // accents. So we remove the grave accents before the escaping and add it back after the escaping. if (text.startsWith("`") && text.endsWith("`")) { String unescaped = text.substring(1, text.length() - 1); return "`" + Escapers.HTML.escape(unescaped) + "`"; } // All none reserved words will be escaped with the default Mustache `HTML` escaper return Escapers.HTML.escape(text); } };
@Override public String escape (String text) { // Fix included as suggested by akkie in #6393 // The given text is a reserved word which is escaped by enclosing it with grave accents. If we would // escape that with the default Mustache `HTML` escaper, then the escaper would also escape our grave // accents. So we remove the grave accents before the escaping and add it back after the escaping. if (text.startsWith("`") && text.endsWith("`")) { String unescaped = text.substring(1, text.length() - 1); return "`" + Escapers.HTML.escape(unescaped) + "`"; } // All none reserved words will be escaped with the default Mustache `HTML` escaper return Escapers.HTML.escape(text); } };
@Override public void execute (Template tmpl, Template.Context ctx, Writer out) { Object value = tmpl.getValueOrDefault(ctx, _name, _line); if (value == null) { throw new MustacheException.Context("No key, method or field with name '" + _name + "' on line " + _line, _name, _line); } write(out, _escaper.escape(_formatter.format(value))); } @Override public void decompile (Delims delims, StringBuilder into) {
@Override public void execute (Template tmpl, Template.Context ctx, Writer out) { Object value = tmpl.getValueOrDefault(ctx, _name, _line); if (value == null) { String msg = Template.isThisName(_name) ? "Resolved '.' to null (which is disallowed), on line " + _line : "No key, method or field with name '" + _name + "' on line " + _line; throw new MustacheException.Context(msg, _name, _line); } write(out, _escaper.escape(_formatter.format(value))); } @Override public void decompile (Delims delims, StringBuilder into) {