Class: Nanoc2::Extra::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/nanoc2/extra/context.rb

Overview

Nanoc2::Extra::Context provides a context and a Binding for use in various filters, such as the ERB and Haml one.

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Context

Creates a new context based off the contents of the hash. Each pair in the hash will be converted to an instance variable. For example, passing the hash { :foo => ‘bar’ } will cause @foo to have the value “bar”.



10
11
12
13
14
# File 'lib/nanoc2/extra/context.rb', line 10

def initialize(hash)
  hash.each_pair do |key, value|
    instance_variable_set('@' + key.to_s, value)
  end
end

Instance Method Details

#get_bindingObject

Returns a binding for this context.



17
18
19
# File 'lib/nanoc2/extra/context.rb', line 17

def get_binding
  binding
end