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   clear_instance_assigns   handle_error   has_key?   invoke   merge   new   pop   push   stack   strainer  

Attributes

environments  [R] 
errors  [R] 
registers  [R] 
scopes  [R] 

Public Class methods

Public Instance methods

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

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]