Module bus.extra

Class FreemarkerTemplate

java.lang.Object
org.miaixz.bus.extra.template.provider.freemarker.FreemarkerTemplate
All Implemented Interfaces:
Serializable, Template

public class FreemarkerTemplate extends Object implements Template, Serializable
Freemarker template implementation. This class wraps a FreeMarker Template object, providing a unified interface for rendering templates.
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    FreemarkerTemplate(freemarker.template.Template freemarkerTemplate)
    Constructs a new FreemarkerTemplate instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    wrap(freemarker.template.Template freemarkerTemplate)
    Wraps a FreeMarker template object into a FreemarkerTemplate instance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.miaixz.bus.extra.template.Template

    render, render
  • Constructor Details

    • FreemarkerTemplate

      public FreemarkerTemplate(freemarker.template.Template freemarkerTemplate)
      Constructs a new FreemarkerTemplate instance.
      Parameters:
      freemarkerTemplate - The raw FreeMarker template object to be wrapped. Must not be null.
  • Method Details

    • wrap

      public static FreemarkerTemplate wrap(freemarker.template.Template freemarkerTemplate)
      Wraps a FreeMarker template object into a FreemarkerTemplate instance.
      Parameters:
      freemarkerTemplate - The raw FreeMarker template object (Template).
      Returns:
      A new FreemarkerTemplate instance, or null if the input freemarkerTemplate is null.
    • render

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

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