Class Liquid::Context
In: lib/liquid/context.rb
Parent: Object

Context keeps the variable stack and resolves variables, as well as keywords

  context['variable'] = 'testing'
  context['variable'] #=> 'testing'
  context['true']     #=> true
  context['10.2232']  #=> 10.2232

  context.stack do
     context['bob'] = 'bobsen'
  end

  context['bob']  #=> nil  class Context

Methods

Attributes

environments  [R] 
errors  [R] 
exception_handler  [RW] 
registers  [R] 
resource_limits  [R] 
scopes  [R] 

Public Class methods

Public Instance methods

Look up variable, either resolve directly after considering the name. We can directly handle Strings, digits, floats and booleans (true,false). If no match is made we lookup the variable in the current scope and later move up to the parent blocks to see if we can resolve the variable somewhere up the tree. Some special keywords return symbols. Those symbols are to be called on the rhs object in expressions

Example:

  products == empty #=> products.empty?

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

Adds filters to this context.

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

Fetches an object starting at the local scope and then moving up the hierachy

are there any not handled interrupts?

Merge a hash of variables in the current local scope

Pop from the stack. use Context#stack instead

pop an interrupt from the stack

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

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

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

[Validate]