ERB/Rails中结束</a>标记的正确缩进

dim*_*nyc 5 html ruby ruby-on-rails erb

有没有办法</a>在link_to帮助器中修复标签的缩进?

在我的.html.erb中:

<%= link_to... do %>
...
<% end %>
Run Code Online (Sandbox Code Playgroud)

在渲染.html:

     <a href="..">
</a><!--fails to inherit the indentation-->
Run Code Online (Sandbox Code Playgroud)

IDE中的2空格缩进:

在此输入图像描述

Chrome的view-source:*:

在此输入图像描述

tom*_*ave 0

这仍然是有效的 HTML,因此您可以忽略它。

这取决于 ERB(由Rails 中的erubis提供支持)如何处理将插入到渲染文本中的字符串缓冲区中的前导和尾随空格。

您可以尝试使用<%= -%>. 另请检查此问题的差异。