java.lang.Object
org.miaixz.bus.extra.template.provider.thymeleaf.ThymeleafProvider
- All Implemented Interfaces:
Serializable,org.miaixz.bus.core.lang.Wrapper<Object>,org.miaixz.bus.core.Provider,TemplateProvider
Thymeleaf template engine implementation. This class provides an implementation of
TemplateProvider for the
Thymeleaf template engine, allowing for configuration and retrieval of Thymeleaf templates. For more information,
see: https://www.thymeleaf.org/- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for ThymeleafProvider.ThymeleafProvider(TemplateConfig config) Constructs a new ThymeleafProvider with the given template configuration.ThymeleafProvider(org.thymeleaf.TemplateEngine engine) Constructs a new ThymeleafProvider with an existing ThymeleafTemplateEngineinstance. -
Method Summary
Modifier and TypeMethodDescriptionorg.thymeleaf.TemplateEnginegetRaw()Provides a hook to access the raw ThymeleafTemplateEngineengine.getTemplate(String resource) Retrieves aTemplateobject based on the provided resource.init(TemplateConfig config) Initializes the template engine with the specified configuration.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.miaixz.bus.core.lang.Wrapper
type
-
Constructor Details
-
ThymeleafProvider
public ThymeleafProvider()Default constructor for ThymeleafProvider. Checks if the Thymeleaf library is available (viaTemplateEngineclass). -
ThymeleafProvider
Constructs a new ThymeleafProvider with the given template configuration.- Parameters:
config- TheTemplateConfigfor initializing the Thymeleaf engine.
-
ThymeleafProvider
public ThymeleafProvider(org.thymeleaf.TemplateEngine engine) Constructs a new ThymeleafProvider with an existing ThymeleafTemplateEngineinstance.- Parameters:
engine- The pre-initializedTemplateEngineinstance.
-
-
Method Details
-
init
Description copied from interface:TemplateProviderInitializes the template engine with the specified configuration.- Specified by:
initin interfaceTemplateProvider- Parameters:
config- TheTemplateConfigcontaining initialization parameters for the template engine.- Returns:
- This
TemplateProviderinstance, initialized with the given configuration.
-
getTemplate
Description copied from interface:TemplateProviderRetrieves aTemplateobject based on the provided resource. The interpretation of the resource string depends on the specific template engine implementation; it could be the template content itself or a relative path to the template file.- Specified by:
getTemplatein interfaceTemplateProvider- Parameters:
resource- The resource identifier for the template.- Returns:
- A
Templateinstance ready for rendering.
-
getRaw
public org.thymeleaf.TemplateEngine getRaw()Provides a hook to access the raw ThymeleafTemplateEngineengine. This can be used for custom configurations or accessing specific Thymeleaf functionalities, such as plugins.- Specified by:
getRawin interfaceorg.miaixz.bus.core.lang.Wrapper<Object>- Returns:
- The raw
TemplateEngineinstance.
-