Class TemplateEngineFactory

java.lang.Object
sonia.scm.template.TemplateEngineFactory

public final class TemplateEngineFactory extends Object
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 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 engines
      defaultEngine - default template engine
  • Method Details

    • getDefaultEngine

      public TemplateEngine 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

      public TemplateEngine getEngine(String engineName)
      Returns template engine by its name. The name of a template engine can be inquired by calling Type.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

      public TemplateEngine getEngineByExtension(String path)
      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

      public Collection<TemplateEngine> getEngines()
      Returns all registered template engines.