diff options
Diffstat (limited to 'actionpack/lib/action_view/render')
-rw-r--r-- | actionpack/lib/action_view/render/partials.rb | 7 | ||||
-rw-r--r-- | actionpack/lib/action_view/render/rendering.rb | 22 |
2 files changed, 18 insertions, 11 deletions
diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index 7f10f54d2e..2eb88ae3e5 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -223,7 +223,7 @@ module ActionView end result = template ? collection_with_template(template) : collection_without_template - result.join(spacer) + result.join(spacer).html_safe! end def collection_with_template(template) @@ -296,7 +296,10 @@ module ActionView end def _find_template(path) - prefix = @view.controller.controller_path unless path.include?(?/) + if controller = @view.controller + prefix = controller.controller_path unless path.include?(?/) + end + @view.find(path, {:formats => @view.formats}, prefix, true) end diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/render/rendering.rb index 0cab035ede..b6f5b9b6d1 100644 --- a/actionpack/lib/action_view/render/rendering.rb +++ b/actionpack/lib/action_view/render/rendering.rb @@ -14,6 +14,7 @@ module ActionView case options when Hash layout = options[:layout] + options[:locals] ||= {} if block_given? return concat(_render_partial(options.merge(:partial => layout), &block)) @@ -25,11 +26,11 @@ module ActionView if file = options[:file] template = find(file, {:formats => formats}) - _render_template(template, layout, :locals => options[:locals] || {}) + _render_template(template, layout, :locals => options[:locals]) elsif inline = options[:inline] _render_inline(inline, layout, options) elsif text = options[:text] - _render_text(text, layout, options) + _render_text(text, layout, options[:locals]) end when :update update_page(&block) @@ -80,16 +81,19 @@ module ActionView def _render_inline(inline, layout, options) handler = Template.handler_class_for_extension(options[:type] || "erb") - template = Template.new(options[:inline], "inline #{options[:inline].inspect}", handler, {}) - locals = options[:locals] || {} + template = Template.new(options[:inline], + "inline #{options[:inline].inspect}", handler, {}) + + locals = options[:locals] content = template.render(self, locals) - content = layout.render(self, locals) {|*name| _layout_for(*name) { content } } if layout - content + _render_text(content, layout, locals) end - def _render_text(text, layout, options) - text = layout.render(self, options[:locals]) { text } if layout - text + def _render_text(content, layout, locals) + content = layout.render(self, locals) do |*name| + _layout_for(*name) { content } + end if layout + content end # This is the API to render a ViewContext's template from a controller. |