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
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 Summary
ConstructorsConstructorDescriptionDefault constructor for BeetlProvider.BeetlProvider(org.beetl.core.GroupTemplate engine) Constructs a new BeetlProvider with an existing BeetlGroupTemplateinstance.BeetlProvider(TemplateConfig config) Constructs a new BeetlProvider with the given template configuration. -
Method Summary
Modifier and TypeMethodDescriptionorg.beetl.core.GroupTemplategetRaw()Provides a hook to access the raw BeetlGroupTemplateengine.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
-
BeetlProvider
public BeetlProvider()Default constructor for BeetlProvider. Checks if the Beetl library is available (viaGroupTemplateclass). -
BeetlProvider
Constructs a new BeetlProvider with the given template configuration.- Parameters:
config- TheTemplateConfigfor initializing the Beetl engine.
-
BeetlProvider
public BeetlProvider(org.beetl.core.GroupTemplate engine) Constructs a new BeetlProvider with an existing BeetlGroupTemplateinstance.- Parameters:
engine- The pre-initializedGroupTemplateinstance.
-
-
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.beetl.core.GroupTemplate getRaw()Provides a hook to access the raw BeetlGroupTemplateengine. This can be used for custom configurations or accessing specific Beetl functionalities, such as plugins.- Specified by:
getRawin interfaceorg.miaixz.bus.core.lang.Wrapper<Object>- Returns:
- The raw
GroupTemplateinstance.
-