class Crinja::Context

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.cr

Constant Summary

AUTOESCAPE_DEFAULT = false

Constructors

Instance Method Summary

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

def self.new(bindings : Variables) #

[View source]
def self.new(parent : Context? = nil, bindings : Variables? = nil) #

[View source]

Instance Method Detail

def []=(key : String, value : Variables) #

Set variable key to value value in local scope.


[View source]
def []=(key : String, value : Value) #

Set variable key to value value in local scope.


[View source]
def []=(key : String, value) #

Set variable key to value value in local scope.


[View source]
def all_macros #

[View source]
def autoescape : Bool? #

[View source]
def autoescape=(autoescape : Bool?) #

[View source]
def autoescape? #

Determines if autoescape is enabled in this or any parent context.


[View source]
def block_context #

[View source]
def block_context=(block_context : NamedTuple(name: String, index: Int32)?) #

[View source]
def extend_path_stack : Crinja::Context::CallStack #

[View source]
def has_macro?(name) #

[View source]
def import_path_stack : Crinja::Context::CallStack #

[View source]
def include_path_stack : Crinja::Context::CallStack #

[View source]
def inspect(io) #

[View source]
def macro(name) : Callable #

[View source]
def macro_stack : Crinja::Context::CallStack #

[View source]
def macros : Hash(String, Crinja::Tag::Macro::MacroFunction) #

[View source]
def merge!(context : Crinja::Context) #

[View source]
def merge!(bindings) #

Merges values in bindings into local scope.


[View source]
def parent : Context? #

Returns the parent context. It must not be altered.


[View source]
def pretty_print(pp) #

[View source]
def register_macro(makro) #

[View source]
def root_macros #

Returns macros defined in the root context.


[View source]
def session_bindings #

Returns the local variables whose scope is this context.


[View source]
def undefined #

Returns an undefined value.


[View source]
def unpack(vars : Array(String), values : Value) #

[View source]