Interface Mustache

All Superinterfaces:
Code
All Known Implementing Classes:
DefaultMustache

public interface Mustache extends Code
The interface to Mustache objects
  • Method Details

    • append

      void append(String text)
      Append text to the mustache output.
      Specified by:
      append in interface Code
      Parameters:
      text - the text to append
    • clone

      Object clone()
      Deep clone of the mustache object.
      Specified by:
      clone in interface Code
      Returns:
      the clone
    • execute

      default Writer execute(Writer writer, Object scope)
      Execute the mustache object with a given writer and a single scope context.
      Parameters:
      writer - write the output of the executed template here
      scope - the root object to use
      Returns:
      the new writer
    • execute

      default Writer execute(Writer writer, Object[] scopes)
    • execute

      Writer execute(Writer writer, List<Object> scopes)
      Execute the mustache with a given writer and an array of scope objects. The scopes are searched right-to-left for references.
      Specified by:
      execute in interface Code
      Parameters:
      writer - write the output of the executed template here
      scopes - an ordered list of scopes for variable resolution
      Returns:
      the new writer
    • getCodes

      Code[] getCodes()
      Get the underlying code objects.
      Specified by:
      getCodes in interface Code
      Returns:
      the array of child codes
    • identity

      void identity(Writer writer)
      Execute the mustache to output itself.
      Specified by:
      identity in interface Code
      Parameters:
      writer - write the output of the executed template here
    • init

      void init()
      Initialize the mustache before executing. This is must be called at least once and is normally called already by the time you have a mustache instance.
      Specified by:
      init in interface Code
    • setCodes

      void setCodes(Code[] codes)
      Change the underlying codes of the mustache implementation.
      Specified by:
      setCodes in interface Code
      Parameters:
      codes - set the children of this code
    • run

      Writer run(Writer writer, List<Object> scopes)
      Only executes the codes. Does not append the text.
      Parameters:
      writer - write the output of the executed template here
      scopes - the array of scopes to execute
      Returns:
      the replacement writer
    • invert

      Node invert(String text)
      Invert this mustache given output text.
      Parameters:
      text - the text to parse
      Returns:
      a tree of nodes representing the variables that when passed as a scope would reproduce the text