Method: Arbre::Context#initialize

Defined in:
lib/arbre/context.rb

#initialize(assigns = nil, helpers = nil, &block) ⇒ Context

Initialize a new Arbre::Context. Any passed block will be instance-exec’d.

Parameters:

  • assigns (Hash) (defaults to: nil)

    A hash of objects which will be made available as instance variables in the context, and in some Arbre elements.

  • helpers (Object) (defaults to: nil)

    An object that has methods on it which will become instance methods within the context. In a Rails set up, this is typically the ActionView::Base instance used to render the view.



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/arbre/context.rb', line 23

def initialize(assigns = nil, helpers = nil, &block)
  @_assigns = (assigns || {}).symbolize_keys
  @_helpers = helpers
  @_element_stack = [ self ]
  @_flow_stack = [ :append ]

  # Pass ourselves as the arbre context to the element.
  super self

  instance_exec &block if block_given?
end