Module bus.extra

Class ThymeleafTemplate

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

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

    • ThymeleafTemplate

      public ThymeleafTemplate(org.thymeleaf.TemplateEngine engine, String template, Charset charset)
      Constructs a new ThymeleafTemplate instance.
      Parameters:
      engine - The Thymeleaf template engine object (TemplateEngine).
      template - The template path or template content.
      charset - The character set for the template. If null, UTF-8 will be used.
  • Method Details

    • wrap

      public static ThymeleafTemplate wrap(org.thymeleaf.TemplateEngine engine, String template, Charset charset)
      Wraps a Thymeleaf template engine and template into a ThymeleafTemplate instance.
      Parameters:
      engine - The Thymeleaf template engine object (TemplateEngine).
      template - The template path or template content.
      charset - The character set for the template.
      Returns:
      A new ThymeleafTemplate instance, or null if the input engine 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.