class Crinja::Context
- Crinja::Context
- Crinja::Util::ScopeMap(String, Crinja::Value)
- Reference
- Object
Overview
A context holds information about the state of runtime execution. This includes tracking of local variables and call stacks, access to global features and configuration settings.
Contexts form a hierarchical structure, where sub-contexts inherit from their parents, but don't pollute the outer contexts with local scoped values. Creating instances is not useful as it’s created automatically at various stages of the template evaluation and should not be created by hand.
Defined in:
runtime/context.crConstant Summary
-
AUTOESCAPE_DEFAULT =
false
Constructors
Instance Method Summary
-
#[]=(key : String, value : Variables)
Set variable key to value value in local scope.
-
#[]=(key : String, value : Value)
Set variable key to value value in local scope.
-
#[]=(key : String, value)
Set variable key to value value in local scope.
- #all_macros
- #autoescape : Bool?
- #autoescape=(autoescape : Bool?)
-
#autoescape?
Determines if autoescape is enabled in this or any parent context.
- #block_context
- #block_context=(block_context : NamedTuple(name: String, index: Int32)?)
- #extend_path_stack : Crinja::Context::CallStack
- #has_macro?(name)
- #import_path_stack : Crinja::Context::CallStack
- #include_path_stack : Crinja::Context::CallStack
- #inspect(io)
- #macro(name) : Callable
- #macro_stack : Crinja::Context::CallStack
- #macros : Hash(String, Crinja::Tag::Macro::MacroFunction)
- #merge!(context : Crinja::Context)
-
#merge!(bindings)
Merges values in bindings into local scope.
-
#parent : Context?
Returns the parent context.
- #pretty_print(pp)
- #register_macro(makro)
-
#root_macros
Returns macros defined in the root context.
-
#session_bindings
Returns the local variables whose scope is this context.
-
#undefined
Returns an undefined value.
- #unpack(vars : Array(String), values : Value)
Instance methods inherited from class Crinja::Util::ScopeMap(String, Crinja::Value)
[](key : K)
[],
[]=(*args, **options)
[]=,
clear(*args, **options)clear(*args, **options, &) clear, delete(*args, **options)
delete(*args, **options, &) delete, entries entries, has_key?(key : K) has_key?, has_value?(value : V) has_value?, inspect(io : IO) inspect, keys keys, merge!(*args, **options)
merge!(*args, **options, &) merge!, parent parent, scope scope, size size, undefined undefined, values values
Constructor methods inherited from class Crinja::Util::ScopeMap(String, Crinja::Value)
new(parent : Crinja::Util::ScopeMap(K, V)? = nil, scope = nil)
new
Constructor Detail
Instance Method Detail
Set variable key to value value in local scope.
Set variable key to value value in local scope.