Interface TemplateEngine


public interface TemplateEngine
The TemplateEngine searches for Templates and prepares the template for the rendering process.
Since:
1.19
  • Method Details

    • getTemplate

      Template getTemplate(String templatePath) throws IOException
      Returns the template associated with the given path. The template engine will search the template in the folder of the web application and in the classpath. This method will return null, if no template could be found for the given path.
      Parameters:
      templatePath - path of the template
      Returns:
      template associated with the given path or null
      Throws:
      IOException
    • getTemplate

      default Template getTemplate(String templatePath, Locale locale) throws IOException
      Returns the template associated with the given path and the given language or the default version. To do this, the template path will be extended with the language. For example `my-template.type` will be extended to `my-template_en.type`, if the language is Locale.ENGLISH. If no dedicated template can be found, the template without the extension will be used.

      The template engine will search the template in the folder of the web application and in the classpath. This method will return null, if no template could be found for the given path.

      Parameters:
      templatePath - path of the template
      locale - the preferred language
      Returns:
      template associated with the given path, extended by the language if found, or null
      Throws:
      IOException
    • getTemplate

      Template getTemplate(String templateIdentifier, Reader reader) throws IOException
      Creates a template of the given reader. Note some template implementations will cache the template by its id.
      Parameters:
      templateIdentifier - id of the template
      reader - template reader
      Returns:
      template created from the reader
      Throws:
      IOException
      Since:
      1.22
    • getType

      TemplateType getType()
    • extendWithLanguage

      static String extendWithLanguage(String templatePath, Locale locale)