Sha256: 22510c9dba026270429d869ac148ac63c71e2e0e52c519d48b07915df9990b9e

Contents?: true

Size: 473 Bytes

Versions: 6

Compression:

Stored size: 473 Bytes

Contents

module Petroglyph
  class Engine

    def initialize(data = nil)
      @data = data
    end

    def render(context = Object.new, locals = {}, file = nil, &block)
      to_hash(locals, file, context, &block).to_json
    end

    def to_hash(locals = {}, file = nil, context = Object.new, &block)
      scope = Scope.new(context, locals, file)

      scope.instance_eval(@data) if @data
      scope.instance_eval(&block) if block_given?

      scope.value
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
petroglyph-0.0.7 lib/petroglyph/engine.rb
petroglyph-0.0.6 lib/petroglyph/engine.rb
petroglyph-0.0.5 lib/petroglyph/engine.rb
petroglyph-0.0.4 lib/petroglyph/engine.rb
petroglyph-0.0.3 lib/petroglyph/engine.rb
petroglyph-0.0.2 lib/petroglyph/engine.rb