【发布时间】:2013-03-21 12:32:15
【问题描述】:
我编写了以下帮助程序:
def section_to_html (block)
case block[0].downcase
when "paragraph"
block.shift
block.each do |value|
return content_tag(:p, value)
end
end
end
目前正在解析这些数组。
["paragraph", "This is the first paragraph."]
["paragraph", "This is the second.", "And here's an extra paragraph."]
然后它返回:
<p>This is the first paragraph.</p>
<p>This is the second.</p>
有没有办法积累 content_tag?所以它返回:
<p>This is the first paragraph.</p>
<p>This is the second.</p>
<p>And here's an extra paragraph.</p>
我现在唯一的解决方案是使用部分代替。但是,一旦我开始向案例条件添加更多内容,这将变得非常混乱。
【问题讨论】:
标签: html ruby-on-rails ruby module helper