Class EvaluationContextImpl
java.lang.Object
io.pebbletemplates.pebble.template.EvaluationContextImpl
- All Implemented Interfaces:
EvaluationContext
,RenderedSizeContext
An evaluation context will store all stateful data that is necessary for the evaluation of a
template. Passing the entire state around will assist with thread safety.
- Author:
- Mitchell
-
Constructor Summary
ConstructorDescriptionEvaluationContextImpl
(PebbleTemplateImpl self, boolean strictVariables, Locale locale, int maxRenderedSize, ExtensionRegistry extensionRegistry, PebbleCache<CacheKey, Object> tagCache, ExecutorService executorService, List<PebbleTemplateImpl> importedTemplates, Map<String, PebbleTemplateImpl> namedImportedTemplates, ScopeChain scopeChain, Hierarchy hierarchy, EvaluationOptions evaluationOptions) Constructor used to provide all final variables. -
Method Summary
Modifier and TypeMethodDescriptionint
addAndGet
(int delta) void
addNamedImportedTemplates
(String alias, PebbleTemplateImpl template) Returns the evaluation options.Returns the executor service if exists or nullReturns the extension registry used to access all of the tests/filters/functionsReturns the data structure representing the entire hierarchy of the template currently being evaluated.Returns a list of imported templates.Returns the localeint
Returns the max rendered size.getNamedImportedTemplate
(String alias) Returns the named imported template.Returns the scope chain data structure that allows variables to be added/removed from the current scope and retrieved from the nearest visible scopes.Returns the cache used for the "cache" taggetVariable
(String key) boolean
Returns whether or not this template is being evaluated in "strict templates" modevoid
scopedShallowWithoutInheritanceChain
(PebbleTemplateImpl template, Map<?, ?> additionalVariables, Callbacks.PebbleConsumer<EvaluationContextImpl> scopedFunction) Makes an exact copy of the evaluation context EXCEPT for the inheritance chain.Makes a "snapshot" of the evaluation context.
-
Constructor Details
-
EvaluationContextImpl
public EvaluationContextImpl(PebbleTemplateImpl self, boolean strictVariables, Locale locale, int maxRenderedSize, ExtensionRegistry extensionRegistry, PebbleCache<CacheKey, Object> tagCache, ExecutorService executorService, List<PebbleTemplateImpl> importedTemplates, Map<String, PebbleTemplateImpl> namedImportedTemplates, ScopeChain scopeChain, Hierarchy hierarchy, EvaluationOptions evaluationOptions) Constructor used to provide all final variables.- Parameters:
self
- The template implementationstrictVariables
- Whether strict variables is to be usedlocale
- The locale of the templateextensionRegistry
- The extension registryexecutorService
- The optional executor servicescopeChain
- The scope chainhierarchy
- The inheritance chaintagCache
- The cache used by the "cache" tag
-
-
Method Details
-
shallowCopyWithoutInheritanceChain
Makes an exact copy of the evaluation context EXCEPT for the inheritance chain. This is necessary for the "include" tag.- Parameters:
self
- The template implementation- Returns:
- A copy of the evaluation context
-
threadSafeCopy
Makes a "snapshot" of the evaluation context. The scopeChain object will be a deep copy and the imported templates will be a new list. This is used for the "parallel" tag.- Parameters:
self
- The template implementation- Returns:
- A copy of the evaluation context
-
getNamedImportedTemplate
Returns the named imported template.- Returns:
- the named imported template.
-
addNamedImportedTemplates
-
isStrictVariables
public boolean isStrictVariables()Returns whether or not this template is being evaluated in "strict templates" mode- Specified by:
isStrictVariables
in interfaceEvaluationContext
- Returns:
- Whether or not this template is being evaluated in "strict templates" mode.
-
getLocale
Returns the locale- Specified by:
getLocale
in interfaceEvaluationContext
- Returns:
- The current locale
-
getMaxRenderedSize
public int getMaxRenderedSize()Returns the max rendered size.- Specified by:
getMaxRenderedSize
in interfaceRenderedSizeContext
- Returns:
- The max rendered size.
-
getExtensionRegistry
Returns the extension registry used to access all of the tests/filters/functions- Returns:
- The extension registry
-
getExecutorService
Returns the executor service if exists or null- Returns:
- The executor service if exists, or null
-
getImportedTemplates
Returns a list of imported templates.- Returns:
- A list of imported templates.
-
getTagCache
Returns the cache used for the "cache" tag- Returns:
- The cache used for the "cache" tag
-
getScopeChain
Returns the scope chain data structure that allows variables to be added/removed from the current scope and retrieved from the nearest visible scopes.- Returns:
- The scope chain.
-
getHierarchy
Returns the data structure representing the entire hierarchy of the template currently being evaluated.- Returns:
- The inheritance chain
-
getEvaluationOptions
Returns the evaluation options.- Returns:
- the evaluation options
-
getVariable
- Specified by:
getVariable
in interfaceEvaluationContext
-
scopedShallowWithoutInheritanceChain
public void scopedShallowWithoutInheritanceChain(PebbleTemplateImpl template, Map<?, ?> additionalVariables, Callbacks.PebbleConsumer<EvaluationContextImpl> scopedFunction) throws IOException- Throws:
IOException
-
addAndGet
public int addAndGet(int delta) - Specified by:
addAndGet
in interfaceRenderedSizeContext
-