Annotation Interface JStacheContentType


Register escapers or filters. A class that is annotated represents a content type such as Html and will be used as a factory for creating escapers as well as a marker for the content type.

There are two supported escaper types:

  • io.jstach.api.runtime.Escaper
  • java.util.function.Function<String,String>
The Function one is desirable if you would like no reference of jstachio runtime api in your code base and or just an easier interface to implement.

On the otherhand the Escaper interfaces allows potentially greater performance if you need to escape native types. n.b. the class annotated does not need to implement the interfaces

Author:
agentgt, Victor Nazarov
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A sentinel null object content type marker to auto resolve the content type based on config found elsewhere.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The charsets supported by the escaper.
    Media Type of the template to help in renderer lookup.
    A static method that will return an implementation of io.jstach.api.runtime.Escaper or Function<String,String>
  • Element Details

    • providesMethod

      A static method that will return an implementation of io.jstach.api.runtime.Escaper or Function<String,String>
      Returns:
      default method name is provider just like the ServiceLoader
      Default:
      "provider"
    • mediaType

      Media Type of the template to help in renderer lookup. The media type information should not include the charset parameter if charsets() is set also for some media types the charset is inherent (e.g. application/json is inherently UTF-8) and should not be included.
      Returns:
      media type of the template or empty string no media type
      Default:
      ""
    • charsets

      The charsets supported by the escaper. If the template is encoded with a different charset a warning will be ommited by the compiler.
      Returns:
      supported charsets.
      Default:
      {}