lib/grape-rabl/formatter.rb in grape-rabl-0.0.2 vs lib/grape-rabl/formatter.rb in grape-rabl-0.0.3
- old
+ new
@@ -9,12 +9,22 @@
def after
status, headers, bodies = *@app_response
current_endpoint = env['api.endpoint']
rabl(current_endpoint) do |template|
- engine = ::Tilt.new(File.join(env['api.tilt.root'], template))
+ engine = ::Tilt.new(view_path(template))
rendered = engine.render(current_endpoint, {})
Rack::Response.new(rendered, status, headers).to_a
+ end
+ end
+
+ private
+
+ def view_path(template)
+ if template.split(".")[-1] == "rabl"
+ File.join(env['api.tilt.root'], template)
+ else
+ File.join(env['api.tilt.root'], (template + ".rabl"))
end
end
def rabl(endpoint)
if template = rablable?(endpoint)