Html Phoenix和具有多个子项的嵌套内容\标记删除嵌套内容

Html Phoenix和具有多个子项的嵌套内容\标记删除嵌套内容,html,tags,elixir,phoenix-framework,Html,Tags,Elixir,Phoenix Framework,我在我的项目中有这样的结构: content_tag(:div, class: "some-class", role: "alert") do content_tag(:button, type: :button, class: "close") do content_tag(:span, class: "some-other-class") do {:safe, ["×"]} end end content_tag(:button,

我在我的项目中有这样的结构:

content_tag(:div, class: "some-class", role: "alert") do
  content_tag(:button, type: :button, class: "close") do
    content_tag(:span, class: "some-other-class") do
      {:safe, ["×"]}
    end
  end
  content_tag(:button, type: :button, class: "close") do
    content_tag(:span, class: "some-other-class") do
      {:safe, ["×"]}
    end
  end
  "<span><b>Some bold text</b>and nothing more</span>"
end
content\u标签(:div,class:“some class”,role:“alert”)do
内容标签(:按钮,类型::按钮,类:“关闭”)do
内容标签(:span,class:“其他类”)是否
{:safe,[“×;”]}
结束
结束
内容标签(:按钮,类型::按钮,类:“关闭”)do
内容标签(:span,class:“其他类”)是否
{:safe,[“×;”]}
结束
结束
“一些粗体文本,仅此而已”
结束
并期望它生成这样的HTML:

<div class="some-class" role="alert">
  <button class="close" type="button">
    &times;
  </button>
  <button class="close" type="button">
    &times;
  </button>
  <span><b>Some bold text</b>and nothing more</span>
</div>

&时代;
&时代;
一些粗体文本,仅此而已
然而,它给了我一些意想不到的东西(为了可读性,我添加了新行-在原始版本中,所有内容都在一行中):


spanb一些粗体文字/band仅此而已/span

我真的不明白,如何将两个嵌套的
内容标签
连接成一个
:safe
字符串,同时使这个字符串
“一些粗体文本,没有更多”
安全且不被转义。

看起来我几乎已经搞懂了。此代码应大致如下所示:

content_tag(:div, class: "some-class", role: "alert") do
  [content_tag(:button, type: :button, class: "close") do
    content_tag(:span, class: "some-other-class") do
      {:safe, ["&times;"]}
    end
  end,
  content_tag(:button, type: :button, class: "close") do
    content_tag(:span, class: "some-other-class") do
      {:safe, ["&times;"]}
    end
  end,
  {:safe, ["<span><b>Some bold text</b>and nothing more</span>"]}]
end
content\u标签(:div,class:“some class”,role:“alert”)do
[内容标签(:按钮,类型::按钮,类:“关闭”)执行
内容标签(:span,class:“其他类”)是否
{:safe,[“×;”]}
结束
完,,
内容标签(:按钮,类型::按钮,类:“关闭”)do
内容标签(:span,class:“其他类”)是否
{:safe,[“×;”]}
结束
完,,
{:安全,[“一些粗体文本,没有更多”]}]
结束
content_tag(:div, class: "some-class", role: "alert") do
  [content_tag(:button, type: :button, class: "close") do
    content_tag(:span, class: "some-other-class") do
      {:safe, ["&times;"]}
    end
  end,
  content_tag(:button, type: :button, class: "close") do
    content_tag(:span, class: "some-other-class") do
      {:safe, ["&times;"]}
    end
  end,
  {:safe, ["<span><b>Some bold text</b>and nothing more</span>"]}]
end