diff options
author | José Valim <jose.valim@gmail.com> | 2010-03-16 23:35:45 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-03-16 23:36:29 +0100 |
commit | 56fb60ebfe9a20ced1366f3e35b2f9bd0bac8e45 (patch) | |
tree | 3874a26e06ac0f4f4bee337b074c94f5d77356a2 /actionpack/lib | |
parent | df735cf5b712312a161d703f2606b145ea2d3b85 (diff) | |
download | rails-56fb60ebfe9a20ced1366f3e35b2f9bd0bac8e45.tar.gz rails-56fb60ebfe9a20ced1366f3e35b2f9bd0bac8e45.tar.bz2 rails-56fb60ebfe9a20ced1366f3e35b2f9bd0bac8e45.zip |
Fix rendering of HTML partials inside JS templates [#4197 status:resolved]
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/render/layouts.rb | 17 | ||||
-rw-r--r-- | actionpack/lib/action_view/template.rb | 2 |
2 files changed, 16 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/render/layouts.rb b/actionpack/lib/action_view/render/layouts.rb index 0cb688ca77..b4720aa681 100644 --- a/actionpack/lib/action_view/render/layouts.rb +++ b/actionpack/lib/action_view/render/layouts.rb @@ -43,10 +43,16 @@ module ActionView # This is the method which actually finds the layout using details in the lookup # context object. If no layout is found, it checkes if at least a layout with # the given name exists across all details before raising the error. - def find_layout(layout) #:nodoc: + # + # If self.formats contains several formats, just the first one is considered in + # the layout lookup. + def find_layout(layout) begin - layout =~ /^\// ? - with_fallbacks { find_template(layout) } : find_template(layout) + if formats.size == 1 + _find_layout(layout) + else + update_details(:formats => self.formats[0,1]){ _find_layout(layout) } + end rescue ActionView::MissingTemplate => e update_details(:formats => nil) do raise unless template_exists?(layout) @@ -54,6 +60,11 @@ module ActionView end end + def _find_layout(layout) #:nodoc: + layout =~ /^\// ? + with_fallbacks { find_template(layout) } : find_template(layout) + end + # Contains the logic that actually renders the layout. def _render_layout(layout, locals, &block) #:nodoc: layout.render(self, locals){ |*name| _layout_for(*name, &block) } diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index b4fdb49d3b..15fafac53d 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -31,7 +31,9 @@ module ActionView format = details[:format] format ||= handler.default_format.to_sym if handler.respond_to?(:default_format) format ||= :html + @formats = [format.to_sym] + @formats << :html if @formats.first == :js end def render(view, locals, &block) |