public.javadoc.org.spincast.plugins.templatingaddon.SpincastTemplatingRequestContextAddon.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-website Show documentation
Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
SpincastTemplatingRequestContextAddon (org.spincast:spincast-framework 1.14.0 API)
org.spincast.plugins.templatingaddon
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
Constructors
Constructor and Description
SpincastTemplatingRequestContextAddon(R requestContext,
TemplatingEngine templatingEngine,
LocaleResolver localeResolver,
JsonManager jsonManager)
-
Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type
Method and Description
void
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
convertTemplatingGlobalVariableValue(Object value)
Converts JsonObject and JsonArray to plain Maps and Lists.
String
createPlaceholder(String variable)
Creates a placeholder using the current templating engine
implementation.
void
deleteAllTemplatingGlobalVariables()
Deletes all global templating variables.
void
deleteTemplatingGlobalVariable(String key)
Deletes a global templating variable.
String
evaluate(String content)
Evaluates some content without any parameters.
String
evaluate(String content,
JsonObject model)
Evaluates some content using the given parameters.
String
evaluate(String content,
JsonObject model,
Locale locale)
Evaluates some content using the given parameters.
String
evaluate(String content,
Map<String,Object> params)
Evaluates some content using the given parameters.
String
evaluate(String content,
Map<String,Object> params,
Locale locale)
Evaluates some content using the given parameters.
String
fromTemplate(String templatePath,
boolean isClasspathPath,
JsonObject model)
Renders a template using the given parameters.
String
fromTemplate(String templatePath,
boolean isClasspathPath,
JsonObject model,
Locale locale)
Renders a template usgin the given parameters.
String
fromTemplate(String templatePath,
boolean isClasspathPath,
Map<String,Object> params)
Renders a template using the given parameters.
String
fromTemplate(String templatePath,
boolean isClasspathPath,
Map<String,Object> params,
Locale locale)
Renders a template usgin the given parameters.
String
fromTemplate(String templatePath,
JsonObject model)
Renders a template using the given parameters.
String
fromTemplate(String templatePath,
JsonObject model,
Locale locale)
Renders a template usgin the given parameters.
String
fromTemplate(String templatePath,
Map<String,Object> params)
Renders a template using the given parameters.
String
fromTemplate(String templatePath,
Map<String,Object> params,
Locale locale)
Renders a template usgin the given parameters.
protected JsonManager
getJsonManager()
protected LocaleResolver
getLocaleResolver()
protected Locale
getLocaleToUse()
protected R
getRequestContext()
Map<String,Object>
getSpincastReservedMap()
Gets the Map reserved for Spincast usage to put some
global templating variables.
protected TemplatingEngine
getTemplatingEngine()
Object
getTemplatingGlobalVariable(String key)
Gets a global templating variable.
Map<String,Object>
getTemplatingGlobalVariables()
The global templating variables.
-
-
Constructor Detail
-
SpincastTemplatingRequestContextAddon
@Inject
public SpincastTemplatingRequestContextAddon(R requestContext,
TemplatingEngine templatingEngine,
LocaleResolver localeResolver,
JsonManager jsonManager)
-
Method Detail
-
getRequestContext
protected R getRequestContext()
-
getTemplatingEngine
protected TemplatingEngine getTemplatingEngine()
-
getLocaleResolver
protected LocaleResolver getLocaleResolver()
-
getJsonManager
protected JsonManager getJsonManager()
-
getLocaleToUse
protected Locale getLocaleToUse()
-
getTemplatingGlobalVariables
public Map<String,Object> getTemplatingGlobalVariables()
Description copied from interface: TemplatingRequestContextAddon
The global templating variables.
- Specified by:
getTemplatingGlobalVariables
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
-
evaluate
public String evaluate(String content,
Map<String,Object> params)
Description copied from interface: TemplatingRequestContextAddon
Evaluates some content using the given parameters.
Uses the Locale
found by the LocaleResolver
.
- Specified by:
evaluate
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
-
evaluate
public String evaluate(String content,
Map<String,Object> params,
Locale locale)
Description copied from interface: TemplatingRequestContextAddon
Evaluates some content using the given parameters.
Uses the specified Locale
.
- Specified by:
evaluate
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
-
evaluate
public String evaluate(String content)
Description copied from interface: TemplatingRequestContextAddon
Evaluates some content without any parameters.
Uses the Locale
found by the LocaleResolver
.
- Specified by:
evaluate
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
-
evaluate
public String evaluate(String content,
JsonObject model)
Description copied from interface: TemplatingRequestContextAddon
Evaluates some content using the given parameters.
Uses the Locale
found by the LocaleResolver
.
- Specified by:
evaluate
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
-
evaluate
public String evaluate(String content,
JsonObject model,
Locale locale)
Description copied from interface: TemplatingRequestContextAddon
Evaluates some content using the given parameters.
Uses the specified Locale
.
- Specified by:
evaluate
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
-
fromTemplate
public String fromTemplate(String templatePath,
JsonObject model)
Description copied from interface: TemplatingRequestContextAddon
Renders a template using the given parameters.
Uses the Locale
found by the LocaleResolver
.
- Specified by:
fromTemplate
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
- Parameters:
templatePath
- must be a classpath's relative path.
-
fromTemplate
public String fromTemplate(String templatePath,
JsonObject model,
Locale locale)
Description copied from interface: TemplatingRequestContextAddon
Renders a template usgin the given parameters.
Uses the Locale
specified.
- Specified by:
fromTemplate
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
- Parameters:
templatePath
- must be a classpath's relative path.
-
fromTemplate
public String fromTemplate(String templatePath,
boolean isClasspathPath,
JsonObject model)
Description copied from interface: TemplatingRequestContextAddon
Renders a template using the given parameters.
Uses the Locale
found by the LocaleResolver
.
- Specified by:
fromTemplate
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
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
public String fromTemplate(String templatePath,
Map<String,Object> params)
Description copied from interface: TemplatingRequestContextAddon
Renders a template using the given parameters.
Uses the Locale
found by the LocaleResolver
.
- Specified by:
fromTemplate
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
- Parameters:
templatePath
- must be a classpath's relative path.
-
fromTemplate
public String fromTemplate(String templatePath,
boolean isClasspathPath,
Map<String,Object> params)
Description copied from interface: TemplatingRequestContextAddon
Renders a template using the given parameters.
Uses the Locale
found by the LocaleResolver
.
- Specified by:
fromTemplate
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
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
public String fromTemplate(String templatePath,
Map<String,Object> params,
Locale locale)
Description copied from interface: TemplatingRequestContextAddon
Renders a template usgin the given parameters.
Uses the Locale
specified.
- Specified by:
fromTemplate
in interface TemplatingRequestContextAddon<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 the Locale
specified.
- Specified by:
fromTemplate
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
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
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 the Locale
specified.
- Specified by:
fromTemplate
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
isClasspathPath
- if true
, the 'templatePath' is considered as
a classpath's relative path. If false
, it is considered as an absolute file
system path.
-
addTemplatingGlobalVariable
public void addTemplatingGlobalVariable(String key,
Object value)
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 interface TemplatingRequestContextAddon<R extends RequestContext<?>>
-
convertTemplatingGlobalVariableValue
protected Object convertTemplatingGlobalVariableValue(Object value)
Converts JsonObject and JsonArray to plain Maps and Lists.
-
addTemplatingGlobalVariables
public void addTemplatingGlobalVariables(Map<String,Object> variables)
Description copied from interface: TemplatingRequestContextAddon
Adds global variables that will be available to any following
evaluation by the templating engine.
- Specified by:
addTemplatingGlobalVariables
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
-
getTemplatingGlobalVariable
public Object getTemplatingGlobalVariable(String key)
Description copied from interface: TemplatingRequestContextAddon
Gets a global templating variable.
- Specified by:
getTemplatingGlobalVariable
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
-
deleteAllTemplatingGlobalVariables
public void deleteAllTemplatingGlobalVariables()
Description copied from interface: TemplatingRequestContextAddon
Deletes all global templating variables.
- Specified by:
deleteAllTemplatingGlobalVariables
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
-
deleteTemplatingGlobalVariable
public void deleteTemplatingGlobalVariable(String key)
Description copied from interface: TemplatingRequestContextAddon
Deletes a global templating variable.
- Specified by:
deleteTemplatingGlobalVariable
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
-
createPlaceholder
public String createPlaceholder(String variable)
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 interface TemplatingRequestContextAddon<R extends RequestContext<?>>
-
getSpincastReservedMap
public Map<String,Object> getSpincastReservedMap()
Description copied from interface: TemplatingRequestContextAddon
Gets the Map reserved for Spincast usage to put some
global templating variables.
- Specified by:
getSpincastReservedMap
in interface TemplatingRequestContextAddon<R extends RequestContext<?>>
Copyright © 2019. All rights reserved.