Sha256: b9ebc8fc0eca9757df461362e73d1e212a840d7517737e1d6bef4f0f9b8d35c4

Contents?: true

Size: 618 Bytes

Versions: 10

Compression:

Stored size: 618 Bytes

Contents

module Nanoc::Extra

  # Nanoc::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

10 entries across 10 versions & 1 rubygems

Version Path
nanoc-2.1.4 lib/nanoc/extra/context.rb
nanoc-2.1 lib/nanoc/extra/context.rb
nanoc-2.1.1 lib/nanoc/extra/context.rb
nanoc-2.1.2 lib/nanoc/extra/context.rb
nanoc-2.1.3 lib/nanoc/extra/context.rb
nanoc-2.1.5 lib/nanoc/extra/context.rb
nanoc-2.1.6 lib/nanoc/extra/context.rb
nanoc-2.2 lib/nanoc/extra/context.rb
nanoc-2.2.1 lib/nanoc/extra/context.rb
nanoc-2.2.2 lib/nanoc/extra/context.rb