Interface ContextJStachio

All Superinterfaces:
JStachio, Renderer<Object>
All Known Implementing Classes:
AbstractJStachio, SpringJStachio

public interface ContextJStachio extends JStachio
A special JStachio that can render models with a loose typed context object bound to "@context".
Since:
1.3.0
Author:
agentgt
See Also:
  • Method Details

    • execute

      <A extends Output<E>, E extends Exception> A execute(Object model, ContextNode context, A appendable) throws E
      Renders the passed in model with a context.
      Type Parameters:
      A - output type
      E - error type
      Parameters:
      model - a model assumed never to be null.
      context - context node bound to "@context".
      appendable - the output to write to.
      Returns:
      the output passed in returned for convenience.
      Throws:
      E - if there is an error writing to the output
    • write

      <A extends Output.EncodedOutput<E>, E extends Exception> A write(Object model, ContextNode context, A output) throws E
      Renders the passed in model with a context directly to a binary stream leveraging pre-encoded parts of the template. This may improve performance when rendering UTF-8 to an OutputStream as some of the encoding is done in advance. Because the encoding is done statically you cannot pass the charset in. The chosen charset comes from JStacheConfig.charset().
      Type Parameters:
      A - output type
      E - error type
      Parameters:
      model - a model assumed never to be null.
      context - context node bound to "@context".
      output - to write to.
      Returns:
      the passed in output for convenience
      Throws:
      E - if an error occurs while writing to output
    • of

      static ContextJStachio of(JStachio jstachio)
      Decorates a JStachio instance as a ContextJStachio if it is not already one.
      Parameters:
      jstachio - the instance to be wrapped.
      Returns:
      the passed in jstachio if it is already a ContextJStachio otherwise wraps the passed in instance.