gpt4 book ai didi

html - Rails 从 Helper 模块返回多个 content_tags

转载 作者:数据小太阳 更新时间:2023-10-29 07:27:14 25 4
gpt4 key购买 nike

我编写了以下助手:

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 - Rails 从 Helper 模块返回多个 content_tags,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15726417/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com