Sha256: db7662182e28ed8b3ed466a1edf240f805284e500286feca198c4ea3228f9113

Contents?: true

Size: 620 Bytes

Versions: 1

Compression:

Stored size: 620 Bytes

Contents

module Nanoc2::Extra

  # Nanoc2::Extra::Context provides a context and a Binding for use in various
  # filters, such as the ERB and Haml one.
  class 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".
    def initialize(hash)
      hash.each_pair do |key, value|
        instance_variable_set('@' + key.to_s, value)
      end
    end

    # Returns a binding for this context.
    def get_binding
      binding
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanoc2-2.2.3 lib/nanoc2/extra/context.rb