# File lib/sinatra/respond_to.rb, line 226 def respond_to(&block) wants = {} def wants.method_missing(type, *args, &handler) self[type] = handler end # Set proper content-type and encoding for # text based formats if [:xml, :gv, :html, :json].include?(format) content_type format, :charset => 'utf-8' end yield wants # Raise this error if requested format is not defined # in respond_to { } block. raise MissingTemplate if wants[format].nil? wants[format].call end