Sha256: 5fe3ccae4330758f078b827d91cb0a22e88039e7b7f4571c86fb6532c1bea136

Contents?: true

Size: 475 Bytes

Versions: 4

Compression:

Stored size: 475 Bytes

Contents

class Mustache
  # A Context represents the context which a Mustache template is
  # executed within. All Mustache tags reference keys in the Context.
  class Context < Hash
    def initialize(mustache)
      @mustache = mustache
      super()
    end

    def [](name)
      if has_key?(name)
        super
      elsif @mustache.respond_to?(name)
        @mustache.send(name)
      else
        raise "Can't find #{name} in #{@mustache.inspect}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mustache-0.3.0 lib/mustache/context.rb
mustache-0.2.2 lib/mustache/context.rb
mustache-0.2.1 lib/mustache/context.rb
mustache-0.2.0 lib/mustache/context.rb