请注意以下内容的可读性和平衡性:
<li class='aclass anotherclass <%= maybeaconditionalclass %>'>
<a href="<%= some stuff %>">
<%= some other stuff %>
</a>
</li>
不幸的是,这会在链接内产生尾随空格,从而导致丑陋的尾随下划线。现在虽然可读性较差,但我可以忍受这个:
<li class='apossibleclass anotherclass <%= maybeaconditionalclass %>'>
<a href="<%= some stuff %>"><%= some other stuff %></a>
</li>
不过,如果我现在考虑这种事情,同样的问题仍然存在:
li.apossibleclass:after {
content: "/";
}
因为结束 A 和 LI 之间的空格妨碍了应该坚持到我的列表项末尾的内容。我只能产生丑陋的混乱作为一种解决方法:
<li class='apossibleclass anotherclass <%= maybeaconditionalclass %>'>
<a href="<%= some stuff %>"><%= some other stuff %></a></li>
Django 提出了一个很好的解决方案:{% spaceless %},所以我在 Rails erb 模板中寻找{% spaceless %}标记的等价物。