Sha256: 02c7e01f6d0b964427e8af8d169bb9e12c4eb7893e313452869ccb9cf9fe928c

Contents?: true

Size: 523 Bytes

Versions: 2

Compression:

Stored size: 523 Bytes

Contents

require 'rabl'
require 'tilt'

module Gon
  module Sinatra
    module Rabl
      class << self
        def cache
          @cache ||= Tilt::Cache.new
        end

        def parse_rabl(rabl_path, controller)
          source = cache.fetch(rabl_path) do
            File.read(rabl_path)
          end

          rabl_engine = ::Rabl::Engine.new(source, :format => 'json')
          output = rabl_engine.render(controller, {})
          ::Rabl.configuration.json_engine.parse(output)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gon-sinatra-0.1.2 lib/gon/sinatra/rabl.rb
gon-sinatra-0.1.1 lib/gon/sinatra/rabl.rb