Module bus.extra

Interface Template

All Known Implementing Classes:
BeetlTemplate, FreemarkerTemplate, ThymeleafTemplate

public interface Template
Abstract template interface. This interface defines the contract for template rendering operations, allowing for various template engines to be used interchangeably.
Since:
Java 17+
Author:
Kimi Liu
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    render(Map<?,?> bindingMap)
    Renders the template with the given binding parameters and returns the result as a String.
    default void
    render(Map<?,?> bindingMap, File file)
    Renders the template with the given binding parameters and writes the result to a specified File.
    void
    render(Map<?,?> bindingMap, OutputStream out)
    Renders the template with the given binding parameters and writes the result to an OutputStream.
    void
    render(Map<?,?> bindingMap, Writer writer)
    Renders the template with the given binding parameters and writes the result to a Writer.
  • Method Details

    • render

      void render(Map<?,?> bindingMap, Writer writer)
      Renders the template with the given binding parameters and writes the result to a Writer.
      Parameters:
      bindingMap - A map of parameters to bind to the template variables.
      writer - The Writer to which the rendered content will be written.
    • render

      void render(Map<?,?> bindingMap, OutputStream out)
      Renders the template with the given binding parameters and writes the result to an OutputStream.
      Parameters:
      bindingMap - A map of parameters to bind to the template variables.
      out - The OutputStream to which the rendered content will be written.
    • render

      default void render(Map<?,?> bindingMap, File file)
      Renders the template with the given binding parameters and writes the result to a specified File. The output stream will be automatically closed after rendering.
      Parameters:
      bindingMap - A map of parameters to bind to the template variables.
      file - The File to which the rendered content will be written.
    • render

      default String render(Map<?,?> bindingMap)
      Renders the template with the given binding parameters and returns the result as a String.
      Parameters:
      bindingMap - A map of parameters to bind to the template variables.
      Returns:
      The rendered content as a String.