Package org.spincast.core.templating
Interface TemplatingRequestContextAddon<R extends RequestContext<?>>
- All Known Implementing Classes:
SpincastTemplatingRequestContextAddon
public interface TemplatingRequestContextAddon<R extends RequestContext<?>>
Provides methods to deal with templating.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addTemplatingGlobalVariable
(String key, Object value) Adds a global variable that will be available to any following evaluation by the templating engine.void
addTemplatingGlobalVariables
(Map<String, Object> variables) Adds global variables that will be available to any following evaluation by the templating engine.createPlaceholder
(String variable) Creates a placeholder using the current templating engine implementation.void
Deletes all global templating variables.void
Deletes a global templating variable.Evaluates some content without any parameters.Evaluates some content using the given parameters.Evaluates some content using the given parameters.evaluate
(String content, JsonObject model) Evaluates some content using the given parameters.evaluate
(String content, JsonObject model, Locale locale) Evaluates some content using the given parameters.fromTemplate
(String templatePath, boolean isClasspathPath, Map<String, Object> params) Renders a template using the given parameters.fromTemplate
(String templatePath, boolean isClasspathPath, Map<String, Object> params, Locale locale) Renders a template usgin the given parameters.fromTemplate
(String templatePath, boolean isClasspathPath, JsonObject model) Renders a template using the given parameters.fromTemplate
(String templatePath, boolean isClasspathPath, JsonObject model, Locale locale) Renders a template usgin the given parameters.fromTemplate
(String templatePath, Map<String, Object> params) Renders a template using the given parameters.Renders a template usgin the given parameters.fromTemplate
(String templatePath, JsonObject model) Renders a template using the given parameters.fromTemplate
(String templatePath, JsonObject model, Locale locale) Renders a template usgin the given parameters.Gets the Map reserved for Spincast usage to put some global templating variables.Gets a global templating variable.The global templating variables.
-
Method Details
-
addTemplatingGlobalVariable
Adds a global variable that will be available to any following evaluation by the templating engine. -
addTemplatingGlobalVariables
Adds global variables that will be available to any following evaluation by the templating engine. -
getTemplatingGlobalVariables
The global templating variables. -
getTemplatingGlobalVariable
Gets a global templating variable. -
deleteAllTemplatingGlobalVariables
void deleteAllTemplatingGlobalVariables()Deletes all global templating variables. -
deleteTemplatingGlobalVariable
Deletes a global templating variable. -
evaluate
Evaluates some content using the given parameters. Uses theLocale
found by theLocaleResolver
. -
evaluate
Evaluates some content using the given parameters. Uses the specifiedLocale
. -
fromTemplate
Renders a template using the given parameters. Uses theLocale
found by theLocaleResolver
.- Parameters:
templatePath
- must be a classpath's relative path.
-
fromTemplate
Renders a template usgin the given parameters. Uses theLocale
specified.- Parameters:
templatePath
- must be a classpath's relative path.
-
fromTemplate
Renders a template using the given parameters. Uses theLocale
found by theLocaleResolver
.- Parameters:
isClasspathPath
- iftrue
, the 'templatePath' is considered as a classpath's relative path. Iffalse
, 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 theLocale
specified.- Parameters:
isClasspathPath
- iftrue
, the 'templatePath' is considered as a classpath's relative path. Iffalse
, it is considered as an absolute file system path.
-
evaluate
Evaluates some content without any parameters.Uses the
Locale
found by theLocaleResolver
. -
evaluate
Evaluates some content using the given parameters. Uses theLocale
found by theLocaleResolver
. -
evaluate
Evaluates some content using the given parameters. Uses the specifiedLocale
. -
fromTemplate
Renders a template using the given parameters. Uses theLocale
found by theLocaleResolver
.- Parameters:
templatePath
- must be a classpath's relative path.
-
fromTemplate
Renders a template usgin the given parameters. Uses theLocale
specified.- Parameters:
templatePath
- must be a classpath's relative path.
-
fromTemplate
Renders a template using the given parameters. Uses theLocale
found by theLocaleResolver
.- Parameters:
isClasspathPath
- iftrue
, the 'templatePath' is considered as a classpath's relative path. Iffalse
, it is considered as an absolute file system path.
-
fromTemplate
Renders a template usgin the given parameters. Uses theLocale
specified.- Parameters:
isClasspathPath
- iftrue
, the 'templatePath' is considered as a classpath's relative path. Iffalse
, it is considered as an absolute file system path.
-
createPlaceholder
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
Gets the Map reserved for Spincast usage to put some global templating variables.
-