lib/deas/sinatra_runner.rb in deas-0.13.1 vs lib/deas/sinatra_runner.rb in deas-0.14.0
- old
+ new
@@ -32,24 +32,50 @@
def halt(*args)
@sinatra_call.halt(*args)
end
+ def redirect(*args)
+ @sinatra_call.redirect(*args)
+ end
+
+ def content_type(*args)
+ return @sinatra_call.content_type if args.empty?
+
+ opts, value = [
+ args.last.kind_of?(::Hash) ? args.pop : {},
+ args.first
+ ]
+ @sinatra_call.content_type(value, {
+ :charset => @sinatra_call.settings.deas_default_charset
+ }.merge(opts || {}))
+ end
+
+ def status(*args)
+ @sinatra_call.status(*args)
+ end
+
+ def headers(*args)
+ @sinatra_call.headers(*args)
+ end
+
def render(template_name, options = nil, &block)
options ||= {}
options[:locals] = { :view => @handler }.merge(options[:locals] || {})
options[:layout] ||= @handler_class.layouts
+
+ self.content_type(get_content_type(template_name)) if self.content_type.nil?
Deas::Template.new(@sinatra_call, template_name, options).render(&block)
end
- def redirect(*args)
- @sinatra_call.redirect(*args)
- end
-
private
def run_callbacks(callbacks)
callbacks.each{|proc| @handler.instance_eval(&proc) }
+ end
+
+ def get_content_type(template_name)
+ File.extname(template_name)[1..-1] || 'html'
end
end
end