class
Marten::Template::Context
- Marten::Template::Context
- Reference
- Object
Overview
A template context.
Defined in:
marten/template/context.crmarten/template/context/block_stack.cr
Constructors
-
.new(values : Hash(String, Value))
Allows to initialize a new context from the specified values.
-
.new
Allows to initialize an empty context.
Class Method Summary
-
.from(values : Context | Hash | NamedTuple | Nil, request : HTTP::Request)
Initializes a context from a hash (or a named tuple) and an HTTP request.
-
.from(values : Context | Hash | NamedTuple | Nil)
Initializes a context from a hash or a named tuple.
Instance Method Summary
-
#[](key : String | Symbol) : Value
Returns a specific context value for a given key.
-
#[]=(key : String | Symbol, value : Value)
Allows to add a new value into the context.
-
#[]=(key : String | Symbol, value)
Allows to add a new value into the context.
-
#[]?(key : String | Symbol) : Value | Nil
Returns a specific context value for a given key or
nilif not found. -
#blocks : Marten::Template::Context::BlockStack
Returns the blocks stack associated with the context.
-
#empty?
Returns
trueif the context is empty. -
#escape? : Bool
Returns
trueif the context is marked for escaping. -
#handler : Marten::Handlers::Base?
Returns the handler instance associated with the context if any.
-
#handler=(handler : Marten::Handlers::Base | Nil)
Allows to set the handler instance associated with the context.
-
#has_key?(key : String | Symbol)
Returns
trueif the context contains the specified key. -
#merge(other_context : self)
Merges another context into the current one.
-
#merge(other_context : Hash | NamedTuple)
Merges a hash or a named tuple of context values into the current context.
-
#stack(&)
Stack another context hash and yields itself.
-
#to_empty
Returns a new empty context that retains the associated handler.
-
#with_escape(new_escape : Bool, &)
Returns a new context for which the escape flag is set to
trueorfalse.
Constructor Detail
Allows to initialize a new context from the specified values.
Class Method Detail
Initializes a context from a hash (or a named tuple) and an HTTP request.
Initializes a context from a hash or a named tuple.
Instance Method Detail
Returns a specific context value for a given key.
Allows to add a new value into the context.
Returns a specific context value for a given key or nil if not found.
Returns the blocks stack associated with the context.
Returns the handler instance associated with the context if any.
Allows to set the handler instance associated with the context.
Merges a hash or a named tuple of context values into the current context.
Returns a new context for which the escape flag is set to true or false.