java.lang.Object
org.miaixz.bus.extra.template.provider.thymeleaf.ThymeleafTemplate
- All Implemented Interfaces:
Serializable,Template
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 Summary
ConstructorsConstructorDescriptionThymeleafTemplate(org.thymeleaf.TemplateEngine engine, String template, Charset charset) Constructs a newThymeleafTemplateinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidrender(Map<?, ?> bindingMap, OutputStream out) Renders the template with the given binding parameters and writes the result to anOutputStream.voidRenders the template with the given binding parameters and writes the result to aWriter.static ThymeleafTemplateWraps a Thymeleaf template engine and template into aThymeleafTemplateinstance.
-
Constructor Details
-
ThymeleafTemplate
Constructs a newThymeleafTemplateinstance.- Parameters:
engine- The Thymeleaf template engine object (TemplateEngine).template- The template path or template content.charset- The character set for the template. Ifnull, 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 aThymeleafTemplateinstance.- 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
ThymeleafTemplateinstance, ornullif the inputengineisnull.
-
render
Description copied from interface:TemplateRenders the template with the given binding parameters and writes the result to aWriter. -
render
Description copied from interface:TemplateRenders the template with the given binding parameters and writes the result to anOutputStream.- Specified by:
renderin interfaceTemplate- Parameters:
bindingMap- A map of parameters to bind to the template variables.out- TheOutputStreamto which the rendered content will be written.
-