Class: Grape::Builder::Renderer
- Inherits:
-
Object
- Object
- Grape::Builder::Renderer
- Defined in:
- lib/grape/builder/renderer.rb
Instance Method Summary collapse
-
#initialize(view_path, template) ⇒ Renderer
constructor
A new instance of Renderer.
- #render(scope, locals = {}) ⇒ Object
Constructor Details
#initialize(view_path, template) ⇒ Renderer
Returns a new instance of Renderer.
4 5 6 |
# File 'lib/grape/builder/renderer.rb', line 4 def initialize(view_path, template) @view_path, @template = view_path, template end |
Instance Method Details
#render(scope, locals = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/grape/builder/renderer.rb', line 8 def render(scope, locals = {}) unless view_path raise "Use Rack::Config to set 'api.tilt.root' in config.ru" end scope.extend Grape::Builder::Scope scope.partial = Grape::Builder::Partial.new(view_path, scope) engine = ::Tilt.new file, nil, view_path: view_path engine.render scope, locals end |