Class Scope
java.lang.Object
io.pebbletemplates.pebble.template.Scope
A scope is a map of variables. A "local" scope ensures that the search for a particular variable
will end at this scope whether or not it was found.
- Author:
- Mitchell
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(String key) Checks if this scope contains a variable of a certain name.Retrieves the variable at this scopegetKeys()Returns keys of all the variables at this scope.booleanisLocal()Returns whether or not this scope is "local".voidAdds a variable to this scopeCreates a shallow copy of the Scope.
-
Constructor Details
-
Scope
Constructor- Parameters:
backingMap- The backing map of variableslocal- Whether this scope is local or not
-
-
Method Details
-
shallowCopy
Creates a shallow copy of the Scope.This is used for the parallel tag because every new thread should have a "snapshot" of the scopes, i.e. one thread should not affect rendering output of another.
It will construct a new collection but it will contain references to all of the original variables therefore it is not a deep copy. This is why it is import for the user to use thread-safe variables when using the parallel tag.
- Returns:
- A copy of the scope
-
put
Adds a variable to this scope- Parameters:
key- The name of the variablevalue- The value of the variable
-
get
Retrieves the variable at this scope- Parameters:
key- The name of the variable- Returns:
- The value of the variable
-
containsKey
Checks if this scope contains a variable of a certain name.- Parameters:
key- The name of the variable- Returns:
- boolean stating whether or not the backing map of this scope contains that variable
-
isLocal
public boolean isLocal()Returns whether or not this scope is "local".- Returns:
- boolean stating whether this scope is local or not.
-
getKeys
Returns keys of all the variables at this scope.- Returns:
- A set of keys
-