Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use to_hash in rabl engine to avoid parsing

Minor breakage: rabl will skip the root then
  • Loading branch information...
commit 7da4c95bc141e0f014ee3a9e565487ee5098cf03 1 parent 655d02b
@skade skade authored
Showing with 4 additions and 6 deletions.
  1. +2 −4 lib/gon/sinatra/rabl.rb
  2. +2 −2 spec/gon/gon_spec.rb
View
6 lib/gon/sinatra/rabl.rb
@@ -1,5 +1,4 @@
require 'rabl'
-require 'json'
module Gon
module Sinatra
@@ -7,9 +6,8 @@ module Rabl
class << self
def parse_rabl(rabl_path, controller)
source = File.read(rabl_path)
- rabl_engine = ::Rabl::Engine.new(source, :format => 'json')
- output = rabl_engine.render(controller, {})
- JSON.parse(output)
+ rabl_engine = ::Rabl::Engine.new(source, :format => 'hash')
+ rabl_engine.render(controller, {})
end
end
end
View
4 spec/gon/gon_spec.rb
@@ -64,8 +64,8 @@ def app
it 'render json from rabl template' do
@gon.clear
@objects = [1,2]
- Gon::Sinatra.rabl 'spec/test_data/sample.rabl', :instance => self
- Gon::Sinatra.objects.length.should == 2
+ @gon.rabl 'spec/test_data/sample.rabl', :instance => self, :as => 'objects'
+ @gon.objects.length.should == 2
end
def request
Please sign in to comment.
Something went wrong with that request. Please try again.