class Marten::Template::Context

Overview

A template context.

Defined in:

marten/template/context.cr
marten/template/context/block_stack.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(values : Hash(String, Value)) #

Allows to initialize a new context from the specified values.


[View source]
def self.new #

Allows to initialize an empty context.


[View source]

Class Method Detail

def self.from(values : Context | Hash | NamedTuple | Nil, request : HTTP::Request) #

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


[View source]
def self.from(values : Context | Hash | NamedTuple | Nil) #

Initializes a context from a hash or a named tuple.


[View source]

Instance Method Detail

def [](key : String) : Value #

Returns a specific context value for a given key.


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

Allows to add a new value into the context.


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

Allows to add a new value into the context.


[View source]
def []?(key : String) : Value | Nil #

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


[View source]

Returns the blocks stack associated with the context.


[View source]
def empty? #

Returns true if the context is empty.


[View source]
def stack(&) #

Stack another context hash and yields itself.


[View source]