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

[]   []=   add_filters   has_key?   invoke   merge   new   pop   push   registers   stack   strainer  

Attributes

scopes  [R] 
template  [R] 

Public Class methods

Public Instance methods

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

adds filters to this context. this does not register the filters with the main Template object. see Template.register_filter for that

merge a hash of variables in the current local scope

pop from the stack. use Context#stack instead

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

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]