Class SpincastTemplatingRequestContextAddon<R extends RequestContext<?>>
java.lang.Object
org.spincast.plugins.templatingaddon.SpincastTemplatingRequestContextAddon<R>
- All Implemented Interfaces:
TemplatingRequestContextAddon<R>
public class SpincastTemplatingRequestContextAddon<R extends RequestContext<?>>
extends Object
implements TemplatingRequestContextAddon<R>
-
Constructor Summary
ConstructorDescriptionSpincastTemplatingRequestContextAddon
(R requestContext, TemplatingEngine templatingEngine, LocaleResolver localeResolver, JsonManager jsonManager) -
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.protected Object
Converts JsonObject and JsonArray to plain Maps and Lists.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.protected JsonManager
protected LocaleResolver
protected Locale
protected R
Gets the Map reserved for Spincast usage to put some global templating variables.protected TemplatingEngine
Gets a global templating variable.The global templating variables.
-
Constructor Details
-
SpincastTemplatingRequestContextAddon
@Inject public SpincastTemplatingRequestContextAddon(R requestContext, TemplatingEngine templatingEngine, LocaleResolver localeResolver, JsonManager jsonManager)
-
-
Method Details
-
getRequestContext
-
getTemplatingEngine
-
getLocaleResolver
-
getJsonManager
-
getLocaleToUse
-
getTemplatingGlobalVariables
Description copied from interface:TemplatingRequestContextAddon
The global templating variables.- Specified by:
getTemplatingGlobalVariables
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
evaluate
Description copied from interface:TemplatingRequestContextAddon
Evaluates some content using the given parameters. Uses theLocale
found by theLocaleResolver
.- Specified by:
evaluate
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
evaluate
Description copied from interface:TemplatingRequestContextAddon
Evaluates some content using the given parameters. Uses the specifiedLocale
.- Specified by:
evaluate
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
evaluate
Description copied from interface:TemplatingRequestContextAddon
Evaluates some content without any parameters.Uses the
Locale
found by theLocaleResolver
.- Specified by:
evaluate
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
evaluate
Description copied from interface:TemplatingRequestContextAddon
Evaluates some content using the given parameters. Uses theLocale
found by theLocaleResolver
.- Specified by:
evaluate
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
evaluate
Description copied from interface:TemplatingRequestContextAddon
Evaluates some content using the given parameters. Uses the specifiedLocale
.- Specified by:
evaluate
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
fromTemplate
Description copied from interface:TemplatingRequestContextAddon
Renders a template using the given parameters. Uses theLocale
found by theLocaleResolver
.- Specified by:
fromTemplate
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
- Parameters:
templatePath
- must be a classpath's relative path.
-
fromTemplate
Description copied from interface:TemplatingRequestContextAddon
Renders a template usgin the given parameters. Uses theLocale
specified.- Specified by:
fromTemplate
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
- Parameters:
templatePath
- must be a classpath's relative path.
-
fromTemplate
Description copied from interface:TemplatingRequestContextAddon
Renders a template using the given parameters. Uses theLocale
found by theLocaleResolver
.- Specified by:
fromTemplate
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
isClasspathPath
- iftrue
, the 'templatePath' is considered as a classpath's relative path. Iffalse
, it is considered as an absolute file system path.
-
fromTemplate
Description copied from interface:TemplatingRequestContextAddon
Renders a template using the given parameters. Uses theLocale
found by theLocaleResolver
.- Specified by:
fromTemplate
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
- Parameters:
templatePath
- must be a classpath's relative path.
-
fromTemplate
Description copied from interface:TemplatingRequestContextAddon
Renders a template using the given parameters. Uses theLocale
found by theLocaleResolver
.- Specified by:
fromTemplate
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
isClasspathPath
- iftrue
, the 'templatePath' is considered as a classpath's relative path. Iffalse
, it is considered as an absolute file system path.
-
fromTemplate
Description copied from interface:TemplatingRequestContextAddon
Renders a template usgin the given parameters. Uses theLocale
specified.- Specified by:
fromTemplate
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
- Parameters:
templatePath
- must be a classpath's relative path.
-
fromTemplate
public String fromTemplate(String templatePath, boolean isClasspathPath, JsonObject model, Locale locale) Description copied from interface:TemplatingRequestContextAddon
Renders a template usgin the given parameters. Uses theLocale
specified.- Specified by:
fromTemplate
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
isClasspathPath
- iftrue
, the 'templatePath' is considered as a classpath's relative path. Iffalse
, it is considered as an absolute file system path.
-
fromTemplate
public String fromTemplate(String templatePath, boolean isClasspathPath, Map<String, Object> params, Locale locale) Description copied from interface:TemplatingRequestContextAddon
Renders a template usgin the given parameters. Uses theLocale
specified.- Specified by:
fromTemplate
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
isClasspathPath
- iftrue
, the 'templatePath' is considered as a classpath's relative path. Iffalse
, it is considered as an absolute file system path.
-
addTemplatingGlobalVariable
Description copied from interface:TemplatingRequestContextAddon
Adds a global variable that will be available to any following evaluation by the templating engine.- Specified by:
addTemplatingGlobalVariable
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
convertTemplatingGlobalVariableValue
Converts JsonObject and JsonArray to plain Maps and Lists. -
addTemplatingGlobalVariables
Description copied from interface:TemplatingRequestContextAddon
Adds global variables that will be available to any following evaluation by the templating engine.- Specified by:
addTemplatingGlobalVariables
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
getTemplatingGlobalVariable
Description copied from interface:TemplatingRequestContextAddon
Gets a global templating variable.- Specified by:
getTemplatingGlobalVariable
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
deleteAllTemplatingGlobalVariables
public void deleteAllTemplatingGlobalVariables()Description copied from interface:TemplatingRequestContextAddon
Deletes all global templating variables.- Specified by:
deleteAllTemplatingGlobalVariables
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
deleteTemplatingGlobalVariable
Description copied from interface:TemplatingRequestContextAddon
Deletes a global templating variable.- Specified by:
deleteTemplatingGlobalVariable
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
createPlaceholder
Description copied from interface:TemplatingRequestContextAddon
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).- Specified by:
createPlaceholder
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
getSpincastReservedMap
Description copied from interface:TemplatingRequestContextAddon
Gets the Map reserved for Spincast usage to put some global templating variables.- Specified by:
getSpincastReservedMap
in interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-