Haml %noscript 标签生成错误的 html 结果
Haml %noscript tag generating wrong html result
这是我在 rails / haml 代码
上的 ruby
%noscript
%iframe{ :src => "https://www.googletagmanager.com/ns.html?id=#{key}", :style => "display:none;visibility:hidden",:height => "0", :width => "0"}
这是预期的 html。
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
但它生成
<noscript>
"
<iframe height='0' src='https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX' style='display:none;visibility:hidden' width='0'></iframe>
"
</noscript>
如您所见,iframe 由“”引号引起来。为什么会这样?
我也尝试使用 src: "..." 而不是使用 :src => "..." 但 id 没有用。
您如何查看生成的 HTML?看起来您正在使用浏览器检查器,它在显示时添加了引号。它们没有出现在实际的 HTML 中。如果您使用“查看源代码”而不是元素检查器,您应该会看到您期望的内容。
这是我在 rails / haml 代码
上的 ruby%noscript
%iframe{ :src => "https://www.googletagmanager.com/ns.html?id=#{key}", :style => "display:none;visibility:hidden",:height => "0", :width => "0"}
这是预期的 html。
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
但它生成
<noscript>
"
<iframe height='0' src='https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX' style='display:none;visibility:hidden' width='0'></iframe>
"
</noscript>
如您所见,iframe 由“”引号引起来。为什么会这样? 我也尝试使用 src: "..." 而不是使用 :src => "..." 但 id 没有用。
您如何查看生成的 HTML?看起来您正在使用浏览器检查器,它在显示时添加了引号。它们没有出现在实际的 HTML 中。如果您使用“查看源代码”而不是元素检查器,您应该会看到您期望的内容。