diff options
Diffstat (limited to 'actionpack/lib/action_view/render/rendering.rb')
-rw-r--r-- | actionpack/lib/action_view/render/rendering.rb | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/render/rendering.rb index 0302e44b4e..48316cac53 100644 --- a/actionpack/lib/action_view/render/rendering.rb +++ b/actionpack/lib/action_view/render/rendering.rb @@ -22,15 +22,18 @@ module ActionView return _render_partial(options) end - layout = find(layout, {:formats => formats}) if layout + template = if options[:file] + find(options[:file], {:formats => formats}) + elsif options[:inline] + handler = Template.handler_class_for_extension(options[:type] || "erb") + Template.new(options[:inline], "inline template", handler, {}) + elsif options[:text] + Template::Text.new(options[:text]) + end - if file = options[:file] - template = find(file, {:formats => formats}) + if template + layout = find(layout, {:formats => formats}) if layout _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[:locals]) end when :update update_page(&block) @@ -76,42 +79,23 @@ module ActionView capture(&block) end - def _render_inline(inline, layout, options) - locals = options[:locals] - - content = ActiveSupport::Notifications.instrument(:render_inline) do - handler = Template.handler_class_for_extension(options[:type] || "erb") - template = Template.new(options[:inline], "inline template", handler, {}) - template.render(self, locals) - end - - _render_text(content, layout, locals) - end - - def _render_text(content, layout, locals) - ActiveSupport::Notifications.instrument(:render_text) - content = _render_layout(layout, locals){ content } if layout - content - end - # This is the API to render a ViewContext's template from a controller. # # Internal Options: # _template:: The Template object to render # _layout:: The layout, if any, to wrap the Template in - # _partial:: true if the template is a partial def render_template(options) _evaluate_assigns_and_ivars - template, layout, partial = options.values_at(:_template, :_layout, :_partial) - _render_template(template, layout, options, partial) + template, layout = options.values_at(:_template, :_layout) + _render_template(template, layout, options) end - def _render_template(template, layout = nil, options = {}, partial = nil) + def _render_template(template, layout = nil, options = {}) locals = options[:locals] || {} content = ActiveSupport::Notifications.instrument(:render_template, :identifier => template.identifier, :layout => (layout ? layout.identifier : nil)) do - partial ? _render_partial_object(template, options) : template.render(self, locals) + template.render(self, locals) end @_content_for[:layout] = content |