diff options
Diffstat (limited to 'actionpack/lib/action_view/template/template.rb')
-rw-r--r-- | actionpack/lib/action_view/template/template.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/actionpack/lib/action_view/template/template.rb b/actionpack/lib/action_view/template/template.rb index dcc5006103..f61dd591a5 100644 --- a/actionpack/lib/action_view/template/template.rb +++ b/actionpack/lib/action_view/template/template.rb @@ -7,13 +7,20 @@ require "action_view/template/path" module ActionView class Template extend TemplateHandlers - attr_reader :source, :identifier, :handler + attr_reader :source, :identifier, :handler, :mime_type, :details def initialize(source, identifier, handler, details) @source = source @identifier = identifier @handler = handler @details = details + + format = details.delete(:format) || begin + # TODO: Clean this up + handler.respond_to?(:default_format) ? handler.default_format.to_sym.to_s : "html" + end + @mime_type = Mime::Type.lookup_by_extension(format.to_s) + @details[:formats] = Array.wrap(format && format.to_sym) end def render(view, locals, &blk) @@ -35,12 +42,7 @@ module ActionView def partial? @details[:partial] end - - # TODO: Move out of Template - def mime_type - Mime::Type.lookup_by_extension(@details[:format].to_s) if @details[:format] - end - + private def compile(locals, view) |