Interface BeCPGTemplateRenderService

All Known Implementing Classes:
FreemarkerTemplateRenderServiceImpl

public interface BeCPGTemplateRenderService

Renders FreeMarker templates that are looked up in the repository first, then on the classpath, so that a customer can override a shipped template without redeploying the module.

Template names are flat, extension included (for instance nutritionFacts-vertical.ftl). The locale is honoured through the standard FreeMarker localized lookup, which tries name_fr_FR.ftl, then name_fr.ftl, then name.ftl. The same rule applies to the templates pulled in by <#import>, so a shared macro library must stay locale-neutral.

Version:
$Id: $Id
Author:
matthieu
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Drops the template cache, so that a template just updated in the repository is picked up without waiting for the update delay.
    boolean
    exists(String templateName, Locale locale)
    Tells whether a template resolves, in the repository or on the classpath.
    render(String templateName, Locale locale, Map<String,Object> model)
    Renders a template and returns its output.
    void
    render(String templateName, Locale locale, Map<String,Object> model, Writer writer)
    Renders a template directly into the given writer, for large outputs.
  • Method Details

    • render

      String render(String templateName, Locale locale, Map<String,Object> model)

      Renders a template and returns its output.

      Parameters:
      templateName - a String object
      locale - a Locale object, the current locale is used when null
      model - a Map object
      Returns:
      a String object
      Throws:
      TemplateRenderException - if the template is missing or fails
    • render

      void render(String templateName, Locale locale, Map<String,Object> model, Writer writer)

      Renders a template directly into the given writer, for large outputs.

      Parameters:
      templateName - a String object
      locale - a Locale object, the current locale is used when null
      model - a Map object
      writer - a Writer object
      Throws:
      TemplateRenderException - if the template is missing or fails
    • exists

      boolean exists(String templateName, Locale locale)

      Tells whether a template resolves, in the repository or on the classpath.

      Parameters:
      templateName - a String object
      locale - a Locale object, the current locale is used when null
      Returns:
      a boolean
    • clearCache

      void clearCache()

      Drops the template cache, so that a template just updated in the repository is picked up without waiting for the update delay.