Created
March 21, 2010 09:11
-
-
Save phs/339170 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://m.onkey.org/2009/7/7/nested-layouts | |
# The "no block given" error crops up in lib/action_view/render/rendering.rb in actionpack. | |
# The #_render_template method # is failing to pass a block to template.render on line 101. | |
# The problem appears to already be fixed in edge, but until then you could try this: | |
#config/initializers/duck_punch_rendering.rb | |
require 'active_support/core_ext/object/try' | |
module ActionView | |
module Rendering | |
def _render_template(template, layout = nil, options = {}) | |
locals = options[:locals] || {} | |
ActiveSupport::Notifications.instrument("action_view.render_template", | |
:identifier => template.identifier, :layout => layout.try(:identifier)) do | |
content = template.render(self, locals) { |*name| _layout_for(*name) } | |
@_content_for[:layout] = content | |
if layout | |
@_layout = layout.identifier | |
content = _render_layout(layout, locals) | |
end | |
content | |
end | |
end | |
end | |
end | |
# eof | |
# Notice the { |*name| _layout_for(*name) } block, which is the thing living on the other | |
# side of your template's yields. | |
# parent_layout becomes | |
module ApplicationHelper | |
def parent_layout(layout) | |
@_content_for[:layout] = self.output_buffer | |
self.output_buffer = render :file => "layouts/#{layout}" | |
end | |
end | |
# eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment