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
ConstructorsConstructorDescriptionSpincastTemplatingRequestContextAddon(R requestContext, TemplatingEngine templatingEngine, LocaleResolver localeResolver, JsonManager jsonManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTemplatingGlobalVariable(String key, Object value) Adds a global variable that will be available to any following evaluation by the templating engine.voidaddTemplatingGlobalVariables(Map<String, Object> variables) Adds global variables that will be available to any following evaluation by the templating engine.protected ObjectConverts JsonObject and JsonArray to plain Maps and Lists.createPlaceholder(String variable) Creates a placeholder using the current templating engine implementation.voidDeletes all global templating variables.voidDeletes 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 JsonManagerprotected LocaleResolverprotected Localeprotected RGets the Map reserved for Spincast usage to put some global templating variables.protected TemplatingEngineGets 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:TemplatingRequestContextAddonThe global templating variables.- Specified by:
getTemplatingGlobalVariablesin interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
evaluate
Description copied from interface:TemplatingRequestContextAddonEvaluates some content using the given parameters. Uses theLocalefound by theLocaleResolver.- Specified by:
evaluatein interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
evaluate
Description copied from interface:TemplatingRequestContextAddonEvaluates some content using the given parameters. Uses the specifiedLocale.- Specified by:
evaluatein interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
evaluate
Description copied from interface:TemplatingRequestContextAddonEvaluates some content without any parameters.Uses the
Localefound by theLocaleResolver.- Specified by:
evaluatein interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
evaluate
Description copied from interface:TemplatingRequestContextAddonEvaluates some content using the given parameters. Uses theLocalefound by theLocaleResolver.- Specified by:
evaluatein interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
evaluate
Description copied from interface:TemplatingRequestContextAddonEvaluates some content using the given parameters. Uses the specifiedLocale.- Specified by:
evaluatein interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
fromTemplate
Description copied from interface:TemplatingRequestContextAddonRenders a template using the given parameters. Uses theLocalefound by theLocaleResolver.- Specified by:
fromTemplatein interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>- Parameters:
templatePath- must be a classpath's relative path.
-
fromTemplate
Description copied from interface:TemplatingRequestContextAddonRenders a template usgin the given parameters. Uses theLocalespecified.- Specified by:
fromTemplatein interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>- Parameters:
templatePath- must be a classpath's relative path.
-
fromTemplate
Description copied from interface:TemplatingRequestContextAddonRenders a template using the given parameters. Uses theLocalefound by theLocaleResolver.- Specified by:
fromTemplatein 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:TemplatingRequestContextAddonRenders a template using the given parameters. Uses theLocalefound by theLocaleResolver.- Specified by:
fromTemplatein interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>- Parameters:
templatePath- must be a classpath's relative path.
-
fromTemplate
Description copied from interface:TemplatingRequestContextAddonRenders a template using the given parameters. Uses theLocalefound by theLocaleResolver.- Specified by:
fromTemplatein 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:TemplatingRequestContextAddonRenders a template usgin the given parameters. Uses theLocalespecified.- Specified by:
fromTemplatein 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:TemplatingRequestContextAddonRenders a template usgin the given parameters. Uses theLocalespecified.- Specified by:
fromTemplatein 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:TemplatingRequestContextAddonRenders a template usgin the given parameters. Uses theLocalespecified.- Specified by:
fromTemplatein 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:TemplatingRequestContextAddonAdds a global variable that will be available to any following evaluation by the templating engine.- Specified by:
addTemplatingGlobalVariablein interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
convertTemplatingGlobalVariableValue
Converts JsonObject and JsonArray to plain Maps and Lists. -
addTemplatingGlobalVariables
Description copied from interface:TemplatingRequestContextAddonAdds global variables that will be available to any following evaluation by the templating engine.- Specified by:
addTemplatingGlobalVariablesin interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
getTemplatingGlobalVariable
Description copied from interface:TemplatingRequestContextAddonGets a global templating variable.- Specified by:
getTemplatingGlobalVariablein interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
deleteAllTemplatingGlobalVariables
public void deleteAllTemplatingGlobalVariables()Description copied from interface:TemplatingRequestContextAddonDeletes all global templating variables.- Specified by:
deleteAllTemplatingGlobalVariablesin interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
deleteTemplatingGlobalVariable
Description copied from interface:TemplatingRequestContextAddonDeletes a global templating variable.- Specified by:
deleteTemplatingGlobalVariablein interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
createPlaceholder
Description copied from interface:TemplatingRequestContextAddonCreates 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:
createPlaceholderin interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-
getSpincastReservedMap
Description copied from interface:TemplatingRequestContextAddonGets the Map reserved for Spincast usage to put some global templating variables.- Specified by:
getSpincastReservedMapin interfaceTemplatingRequestContextAddon<R extends RequestContext<?>>
-