Interface TemplateEngine

  • All Known Implementing Classes:
    DefaultDataTemplateEngine
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface TemplateEngine
    Abstraction to renderFile templates using a data model.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default java.lang.String render​(java.lang.String templatePath)
      Renders a template loaded from the given path and returns the result.
      default java.lang.String render​(java.lang.String templatePath, java.util.Map<java.lang.String,​java.lang.Object> dataModel)
      Renders a template loaded from the given path and returns the result.
      void write​(java.lang.String templatePath, java.io.Writer out, java.util.Map<java.lang.String,​java.lang.Object> dataModel)
      Writes a template to the given writer.
    • Method Detail

      • write

        void write​(java.lang.String templatePath,
                   java.io.Writer out,
                   java.util.Map<java.lang.String,​java.lang.Object> dataModel)
        Writes a template to the given writer.
        Parameters:
        templatePath - Loaded template to render.
        out - Writer to write to.
        dataModel - Data model to apply to the template.
      • render

        default java.lang.String render​(java.lang.String templatePath,
                                        java.util.Map<java.lang.String,​java.lang.Object> dataModel)
        Renders a template loaded from the given path and returns the result.
        Parameters:
        templatePath - Path to a template to load.
        dataModel - Data model to apply to the template.
        Returns:
        Returns the rendered text of the template.
      • render

        default java.lang.String render​(java.lang.String templatePath)
        Renders a template loaded from the given path and returns the result.
        Parameters:
        templatePath - Path to a template to load.
        Returns:
        Returns the rendered text of the template.