This method is triggered after this helper is registred within Sinatra. We need to overide the default render method to supply correct path to the template, since Sinatra is by default looking in the current __FILE__ path
# File lib/sinatra/rack_accept.rb, line 28 def self.registered(app) app.helpers Rack::RespondTo::Helpers app.class_eval do alias :render_without_format :render def render(*args, &block) begin assumed_layout = args[1] == :layout args[1] = "#{args[1]}.#{@media_type}".to_sym if args[1].is_a?(::Symbol) render_without_format *args, &block rescue Errno::ENOENT => e raise "ERROR: Missing template: #{args[1]}.#{args[0]}" unless assumed_layout raise e end end private :render end end
# File lib/sinatra/rack_accept.rb, line 32 def render(*args, &block) begin assumed_layout = args[1] == :layout args[1] = "#{args[1]}.#{@media_type}".to_sym if args[1].is_a?(::Symbol) render_without_format *args, &block rescue Errno::ENOENT => e raise "ERROR: Missing template: #{args[1]}.#{args[0]}" unless assumed_layout raise e end end
Generated with the Darkfish Rdoc Generator 2.