Interface TemplatingRequestContextAddon<R extends RequestContext<?>>

All Known Implementing Classes:
SpincastTemplatingRequestContextAddon

public interface TemplatingRequestContextAddon<R extends RequestContext<?>>
Provides methods to deal with templating.
  • Method Details

    • addTemplatingGlobalVariable

      void addTemplatingGlobalVariable(String key, Object value)
      Adds a global variable that will be available to any following evaluation by the templating engine.
    • addTemplatingGlobalVariables

      void addTemplatingGlobalVariables(Map<String,Object> variables)
      Adds global variables that will be available to any following evaluation by the templating engine.
    • getTemplatingGlobalVariables

      Map<String,Object> getTemplatingGlobalVariables()
      The global templating variables.
    • getTemplatingGlobalVariable

      Object getTemplatingGlobalVariable(String key)
      Gets a global templating variable.
    • deleteAllTemplatingGlobalVariables

      void deleteAllTemplatingGlobalVariables()
      Deletes all global templating variables.
    • deleteTemplatingGlobalVariable

      void deleteTemplatingGlobalVariable(String key)
      Deletes a global templating variable.
    • evaluate

      String evaluate(String content, Map<String,Object> params)
      Evaluates some content using the given parameters. Uses the Locale found by the LocaleResolver.
    • evaluate

      String evaluate(String content, Map<String,Object> params, Locale locale)
      Evaluates some content using the given parameters. Uses the specified Locale.
    • fromTemplate

      String fromTemplate(String templatePath, Map<String,Object> params)
      Renders a template using the given parameters. Uses the Locale found by the LocaleResolver.
      Parameters:
      templatePath - must be a classpath's relative path.
    • fromTemplate

      String fromTemplate(String templatePath, Map<String,Object> params, Locale locale)
      Renders a template usgin the given parameters. Uses the Locale specified.
      Parameters:
      templatePath - must be a classpath's relative path.
    • fromTemplate

      String fromTemplate(String templatePath, boolean isClasspathPath, Map<String,Object> params)
      Renders a template using the given parameters. Uses the Locale found by the LocaleResolver.
      Parameters:
      isClasspathPath - if true, the 'templatePath' is considered as a classpath's relative path. If false, it is considered as an absolute file system path.
    • fromTemplate

      String fromTemplate(String templatePath, boolean isClasspathPath, Map<String,Object> params, Locale locale)
      Renders a template usgin the given parameters. Uses the Locale specified.
      Parameters:
      isClasspathPath - if true, the 'templatePath' is considered as a classpath's relative path. If false, it is considered as an absolute file system path.
    • evaluate

      String evaluate(String content)
      Evaluates some content without any parameters.

      Uses the Locale found by the LocaleResolver.

    • evaluate

      String evaluate(String content, JsonObject model)
      Evaluates some content using the given parameters. Uses the Locale found by the LocaleResolver.
    • evaluate

      String evaluate(String content, JsonObject model, Locale locale)
      Evaluates some content using the given parameters. Uses the specified Locale.
    • fromTemplate

      String fromTemplate(String templatePath, JsonObject model)
      Renders a template using the given parameters. Uses the Locale found by the LocaleResolver.
      Parameters:
      templatePath - must be a classpath's relative path.
    • fromTemplate

      String fromTemplate(String templatePath, JsonObject model, Locale locale)
      Renders a template usgin the given parameters. Uses the Locale specified.
      Parameters:
      templatePath - must be a classpath's relative path.
    • fromTemplate

      String fromTemplate(String templatePath, boolean isClasspathPath, JsonObject model)
      Renders a template using the given parameters. Uses the Locale found by the LocaleResolver.
      Parameters:
      isClasspathPath - if true, the 'templatePath' is considered as a classpath's relative path. If false, it is considered as an absolute file system path.
    • fromTemplate

      String fromTemplate(String templatePath, boolean isClasspathPath, JsonObject model, Locale locale)
      Renders a template usgin the given parameters. Uses the Locale specified.
      Parameters:
      isClasspathPath - if true, the 'templatePath' is considered as a classpath's relative path. If false, it is considered as an absolute file system path.
    • createPlaceholder

      String createPlaceholder(String variable)
      Creates a placeholder using the current templating engine implementation.

      This is mainly useful for the tests, which don't know in advance which templating engine will be used, so which syntax to use for the placeholders.

      For example, using Pebble, a call to createPlaceholder("name") will result in "{{name}}" (without the quotes).

    • getSpincastReservedMap

      Map<String,Object> getSpincastReservedMap()
      Gets the Map reserved for Spincast usage to put some global templating variables.