开发者

Rails 3 Beta 2, Haml, Nested Layouts and LocalJumpError

开发者 https://www.devze.com 2022-12-26 18:46 出处:网络
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 lik

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 th开发者_如何转开发is, I get a LocalJumpError with the message no block given. The stack traces are blank and pretty unhelpful. Any ideas? Are these known issues?


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消