class Liquid::Context

Defined in:

liquid/context.cr

Constant Summary

FLOATS = /^(-?\d[\d\.]+)$/
INTEGERS = /^(-?\d+)$/
LITERALS = Regex.union([FLOATS, INTEGERS, RANGES, STRINGS])
RANGES = /^\((\S+)\.\.(\S+)\)$/
SquareBracketed = /^\[(.*)\]$/
STRINGS = /^['"](.*)['"]$/

Constructors

Instance Method Summary

Constructor Detail

def self.new(environments : Array(Hash(String, Liquid::Type)) = [] of Hash(String, Type), outer_scope = {} of String => Type, registers = {} of Symbol => Type, rethrow_errors : Bool = false) #

[View source]

Instance Method Detail

def [](key) #

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

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

Only allow String, Numeric, Hash, Array, Proc, Boolean or Liquid::Drop


[View source]
def add_filters(filters : Array(Filter.class) | Filter.class) #

Adds filters to this context.

Note that this does not register the filters with the main Template object. see Template.register_filter for that


[View source]
def clear_instance_assigns #

[View source]
def environments : Array(Hash(String, Liquid::Type)) #

[View source]
def errors : Array(Exception) #

[View source]
def fetch(key) #

[View source]
def handle_error(e) #

[View source]
def has_interrupt? #

are there any not handled interrupts?


[View source]
def has_key?(key) #

[View source]
def invoke(method, *args) #

[View source]
def merge(new_scopes) #

Merge a hash of variables in the current local scope


[View source]
def pop #

Pop from the stack. use Context#stack instead


[View source]
def pop_interrupt #

pop an interrupt from the stack


[View source]
def push(new_scope = {} of String => Type) #

Push new local scope on the stack. use Context#stack instead


[View source]
def push_interrupt(e) #

push an interrupt to the stack. this interrupt is considered not handled.


[View source]
def registers : Liquid::RegisterCollection #

[View source]
def scopes : Array(Hash(String, Type)) #

[View source]
def stack(new_scope = {} of String => Type, &) #

Pushes a new local scope on the stack, pops it at the end of the block

Example: context.stack do context["var"] = "hi" end

context["var] #=> nil


[View source]
def strainer #

[View source]
def to_liquid #

[View source]