Package sonia.scm.template
Class TemplateEngineFactory
java.lang.Object
sonia.scm.template.TemplateEngineFactory
The
TemplateEngineFactory
is the entrypoint of the template api.
The factory return available template engines. The
TemplateEngineFactory
is available via injection.- Since:
- 1.19
-
Constructor Summary
ConstructorsConstructorDescriptionTemplateEngineFactory
(Set<TemplateEngine> engines, TemplateEngine defaultEngine) Constructs new template engine factory. -
Method Summary
Modifier and TypeMethodDescriptionReturns the default template engine.Returns template engine by its name.getEngineByExtension
(String path) Returns template engine by its extension.Returns all registered template engines.
-
Constructor Details
-
TemplateEngineFactory
@Inject public TemplateEngineFactory(Set<TemplateEngine> engines, @Default TemplateEngine defaultEngine) Constructs new template engine factory. This constructor should only be called from the injection framework.- Parameters:
engines
- Set of available template enginesdefaultEngine
- default template engine
-
-
Method Details
-
getDefaultEngine
Returns the default template engine. In the normal case this should be an implementation of the mustache template system.- Returns:
- default template engine
-
getEngine
Returns template engine by its name. The name of a template engine can be inquired by callingType.getName()
. If no engine with the given name registered this method will return null.- Parameters:
engineName
- name of the engine- Returns:
- engine with the given name or null
-
getEngineByExtension
Returns template engine by its extension. This method will use the extension of the given path and search a template engine for this extension. If no extension could be found in the the path, the method will handle the whole path as a extension. If no engine could be found for the given extension, this method will return null.- Parameters:
path
- template path with extension- Returns:
- template engine for the given path or null
-
getEngines
Returns all registered template engines.
-