Browse files

Fix a bug where render :text could not handle yield :symbol. Fixes gu…

…ides generation
  • Loading branch information...
1 parent 6395c7b commit b9ce8216fa849a47ad0b0f99fa510e226a23c12e @wycats wycats committed Oct 10, 2009
Showing with 13 additions and 9 deletions.
  1. +13 −9 actionpack/lib/action_view/render/rendering.rb
View
22 actionpack/lib/action_view/render/rendering.rb
@@ -14,6 +14,7 @@ def render(options = {}, locals = {}, &block) #:nodoc:
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 @@ def render(options = {}, locals = {}, &block) #:nodoc:
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 @@ def _layout_for(name = nil)
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.

1 comment on commit b9ce821

@wycats

h/t xavier noria for reporting this bug

Please sign in to comment.