Ruby on rails rails html助手

Ruby on rails rails html助手,ruby-on-rails,haml,partials,Ruby On Rails,Haml,Partials,我试图找出最干净的方法来生成一点html并在其中嵌套内容。使用HAML。基本上我想做一些事情,比如: = block_large This is some nested content 这将产生: <div class="block large"> <img src="block_large_carat.gif" class="block_large_carat"> This is some nested content </div> 这是一

我试图找出最干净的方法来生成一点html并在其中嵌套内容。使用HAML。基本上我想做一些事情,比如:

= block_large
  This is some nested content
这将产生:

<div class="block large">
  <img src="block_large_carat.gif" class="block_large_carat">
  This is some nested content
</div>

这是一些嵌套内容
问题是我不知道如何实现这一目标。分部?帮手?我被挂断了,我将如何嵌套我想要的任何内容。试图保持我的HAML干燥,不想一次又一次地明确声明图像标记。

编辑:
我以前的解决方案无效:)
感谢EmFi指出这一点。
这次我(甚至)测试了它,它(甚至)工作了\o/

我在这里发布这篇文章是基于。
请阅读全文,以获得更好的解释:)

app/helpers/application_helper.rb app/views/xxx/new.html.haml app/views/xxx/_block_large.html.haml 呈现:

这是一些嵌套内容
哎呀。。

希望有帮助

分部作为一种方式是有意义的。好吧,但是如何在分部中嵌套内容呢?Rails noob here=p您不能将块传递给partials。助手是更好的选择。但是我现在没有时间发布一个例子。不好。指定给渲染的块仅使用render:update.True进行处理。(真不好意思)修好了。谢谢你的回答。我还没有机会尝试一下,但这是有道理的:)
  def block_to_partial(partial_name, options = {}, &block)
    options.merge!(:body => capture(&block))
    concat(render(:partial => partial_name, :locals => options), block.binding)
  end
%h2 Test!
- block_to_partial("block_large", :class_name=>"nested_content") do
  This is some nested content
OOps..
#block_large
  %img(src="block_large_carat.gif" class="block_large_carat")
  %div(class=class_name)
    = body
<div id='block_large'>
  <img class='block_large_carat' src='block_large_carat.gif' />
  <div class='nested_content'>
    This is some nested content
  </div>
</div>
OOps..