Module: Sinatra::React::Helpers
- Defined in:
- lib/sinatra/react.rb
Instance Method Summary collapse
Instance Method Details
#find_template(views, name, engine, &block) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/sinatra/react.rb', line 20 def find_template(views, name, engine, &block) if engine == Tilt::ReactTemplate views = Tilt::ReactTemplate.components end super(views, name, engine, &block) end |
#react(component, opts = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sinatra/react.rb', line 8 def react(component, opts = {}) req = Rack::Accept::MediaType.new(request.env['HTTP_ACCEPT']) if req.accept?('text/html') return render :jsx, component, opts elsif req.accept?('application/json') content_type :json return json_for_props(component, opts[:locals]) else halt 406 end end |