In package com.mitchellbosecke.pebble.template
public class Scope extends Object
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.
Constructors
public Scope(Map<String, Object> backingMap, boolean local)
Constructor
-
Map<String, Object> backingMap
The backing map of variables
-
boolean local
Whether this scope is local or not
Methods
public Scope 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.
- No parameters
public void put(String key, Object value)
Adds a variable to this scope
-
String key
The name of the variable
-
Object value
The value of the variable
public Object get(String key)
Retrieves the variable at this scope
-
String key
The name of the variable
public boolean containsKey(String key)
Checks if this scope contains a variable of a certain name.
-
String key
The name of the variable
public boolean isLocal()
Returns whether or not this scope is "local".
- No parameters
public Set<String> getKeys()
Returns keys of all the variables at this scope.
- No parameters