views:

566

answers:

2

Alright, I'm trying to create an app with nested templates. I'm using Rails 3 Beta 2 and Haml. I've poked around and I've decided to take the clearest approach and have structured my templates like so:

# application.html.haml
!!!
%body
  %h1 Outermost Template
  = yield(:foobar)

# inner.html.haml
- content_for :foobar do
  %h2 Inner Template
  = yield

= render :file => 'layouts/application'

# foo_controller.rb
layout 'inner'

With all of this, I get a LocalJumpError with the message no block given. The stack traces are blank and pretty unhelpful. Any ideas? Are these known issues?

+2  A: 

content_for blocks shouldn't contain yield. They aren't passed a block themselves, which is where your error message is coming from.

nex3
+2  A: 

give:

def inside_layout layout = 'application', &block
  render :inline => capture_haml(&block), :layout => "layouts/#{layout}"
end

a try. Use like http://m.onkey.org/2009/7/7/nested-layouts

jdwyah