Class Html

java.lang.Object
io.jstach.jstachio.escapers.Html

@JStacheContentType(mediaType="text/html", charsets="UTF-8") public final class Html extends Object
Provides a mustache spec based HTML escaper which is the default in normal mustache.

The escaper simply escapes:

Escape table
Character Escaped String
'"' """
'&' "&"
''' "'"
'<' "&lt;"
'=' "&#x3D;"
'>' "&gt;"
'`' "&#x60;"

N.B. Unlike many XML escapers this escaper does not differentiate attribute and element content. Furthermore Mustache unlike many other templating languages is content agnostic. If more flexibile attribute escaping is needed a custom lambda could be used to preserve the whitespace in attributes.

This escaper assumes UTF-8 which is the predominate encoding of HTML these days and thus will not encode characters other then the ones mentioned above. Thus if you intend escape for example StandardCharsets.US_ASCII a different HTML escaper should be used to properly escape non ascii characters as HTML entities.

Author:
agentgt, Victor Nazarov
See Also:
  • Method Details

    • provider

      public static Escaper provider()
      Provides the escaper.
      Returns:
      HTML escaper.
    • of

      public static Escaper of()
      Provides the escaper.
      Returns:
      HTML escaper.