Module bus.extra

Class ThymeleafProvider

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

public class ThymeleafProvider extends Object implements 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 Details

    • ThymeleafProvider

      public ThymeleafProvider()
      Default constructor for ThymeleafProvider. Checks if the Thymeleaf library is available (via TemplateEngine class).
    • ThymeleafProvider

      public ThymeleafProvider(TemplateConfig config)
      Constructs a new ThymeleafProvider with the given template configuration.
      Parameters:
      config - The TemplateConfig for initializing the Thymeleaf engine.
    • ThymeleafProvider

      public ThymeleafProvider(org.thymeleaf.TemplateEngine engine)
      Constructs a new ThymeleafProvider with an existing Thymeleaf TemplateEngine instance.
      Parameters:
      engine - The pre-initialized TemplateEngine instance.
  • Method Details

    • init

      public TemplateProvider init(TemplateConfig config)
      Description copied from interface: TemplateProvider
      Initializes the template engine with the specified configuration.
      Specified by:
      init in interface TemplateProvider
      Parameters:
      config - The TemplateConfig containing initialization parameters for the template engine.
      Returns:
      This TemplateProvider instance, initialized with the given configuration.
    • getTemplate

      public Template getTemplate(String resource)
      Description copied from interface: TemplateProvider
      Retrieves a Template object 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:
      getTemplate in interface TemplateProvider
      Parameters:
      resource - The resource identifier for the template.
      Returns:
      A Template instance ready for rendering.
    • getRaw

      public org.thymeleaf.TemplateEngine getRaw()
      Provides a hook to access the raw Thymeleaf TemplateEngine engine. This can be used for custom configurations or accessing specific Thymeleaf functionalities, such as plugins.
      Specified by:
      getRaw in interface org.miaixz.bus.core.lang.Wrapper<Object>
      Returns:
      The raw TemplateEngine instance.