lib/deas/sinatra_runner.rb in deas-0.27.0 vs lib/deas/sinatra_runner.rb in deas-0.28.0

- old
+ new

@@ -38,22 +38,32 @@ def headers(*args) @sinatra_call.headers(*args) end - def render(template_name, opts = nil, &block) + def render(template_name, opts = nil) self.content_type(get_content_type(template_name)) if self.content_type.nil? - # TODO: move to DeasRunner, don't pass sinatra call to create template - # def render(template_name, *args, &block) - # super(template_name, *args, &block) options = opts || {} options[:locals] = { :view => self.handler, :logger => self.logger }.merge(options[:locals] || {}) options[:layout] = self.handler_class.layouts if !options.key?(:layout) - Deas::Template.new(@sinatra_call, template_name, options).render(&block) + + if self.template_source.engine_for?(template_name) + self.template_source.render(template_name, self.handler, options[:locals]) + else + Deas::Template.new(@sinatra_call, template_name, options).render + end + end + + def partial(template_name, locals = nil) + if self.template_source.engine_for?(template_name) + self.template_source.partial(template_name, locals || {}) + else + Deas::Template::Partial.new(@sinatra_call, template_name, locals).render + end end def send_file(*args, &block) @sinatra_call.send_file(*args, &block) end