Module bus.extra

Class BeetlProvider

java.lang.Object
org.miaixz.bus.extra.template.provider.beetl.BeetlProvider
All Implemented Interfaces:
Serializable, org.miaixz.bus.core.lang.Wrapper<Object>, org.miaixz.bus.core.Provider, TemplateProvider

public class BeetlProvider extends Object implements TemplateProvider
Beetl template engine encapsulation. This class provides an implementation of TemplateProvider for the Beetl template engine, allowing for configuration and retrieval of Beetl templates.
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Constructor Details

    • BeetlProvider

      public BeetlProvider()
      Default constructor for BeetlProvider. Checks if the Beetl library is available (via GroupTemplate class).
    • BeetlProvider

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

      public BeetlProvider(org.beetl.core.GroupTemplate engine)
      Constructs a new BeetlProvider with an existing Beetl GroupTemplate instance.
      Parameters:
      engine - The pre-initialized GroupTemplate 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.beetl.core.GroupTemplate getRaw()
      Provides a hook to access the raw Beetl GroupTemplate engine. This can be used for custom configurations or accessing specific Beetl functionalities, such as plugins.
      Specified by:
      getRaw in interface org.miaixz.bus.core.lang.Wrapper<Object>
      Returns:
      The raw GroupTemplate instance.