class

Marten::Template::Context

Inherits Reference / Object

A template context.

Constructors

new(values : Hash(String, Value))

Allows to initialize a new context from the specified values.

Source
new

Allows to initialize an empty context.

Source

Class methods

from(values : Context | Hash | NamedTuple | Nil, request : HTTP::Request)

Initializes a context from a hash (or a named tuple) and an HTTP request.

Source
from(values : Context | Hash | NamedTuple | Nil)

Initializes a context from a hash or a named tuple.

Source

Instance methods

[](key : String | Symbol) : Value

Returns a specific context value for a given key.

Source
[]=(key : String | Symbol, value : Value)

Allows to add a new value into the context.

Source
[]=(key : String | Symbol, value)

Allows to add a new value into the context.

Source
[]?(key : String | Symbol) : Value | Nil

Returns a specific context value for a given key or nil if not found.

Source
blocks

Returns the blocks stack associated with the context.

Source
empty?

Returns true if the context is empty.

Source
escape?

Returns true if the context is marked for escaping.

Source
handler

Returns the handler instance associated with the context if any.

Source
handler=(handler : Marten::Handlers::Base | Nil)

Allows to set the handler instance associated with the context.

Source
has_key?(key : String | Symbol)

Returns true if the context contains the specified key.

Source
merge(other_context : self)

Merges another context into the current one.

Source
merge(other_context : Hash | NamedTuple)

Merges a hash or a named tuple of context values into the current context.

Source
stack

Stack another context hash and yields itself.

Source
to_empty

Returns a new empty context that retains the associated handler.

Source
with_escape(new_escape : Bool, &)

Returns a new context for which the escape flag is set to true or false.

Source

Nested types