Is there an equivalent to Smarty's {strip} in erb?
To clarify:
I'm not looking for .strip. Read the docs on Smarty's {strip};
Whitespace between tags is significant and matters very much when you try to match widths and so on. For example, if you have this code:
<ul>
<li>Something</li>
<li>Something else</li>
</ul>
and the lis have display: inline, there will be a space between them even if they have no margin. That space appears because of the whitespace between </li> and <li>. So, the only solution to not have that space between the <li>s is to do this:
<ul><li>Something</li><li>Something else</li></ul>
Which is pretty fugly and you 开发者_JAVA百科end up with huge, unreadable lines when you start putting <a>s in the <li>s and so on.
There is always the "traditional" method of putting spaces inside the tags (still valid XML):
<ul
><li><a href="#">bla</a></li
><li><a href="#">bla</a></li
></ul>
You have the following options
- in Haml you can do with
>and< - in ERB the
ERB::Compiler::TrimScannermaybe could help you out, but I've never used it. As far as I understand, it would look like this:<%w capture do %> here comes your code with whitespaces <% end %>
加载中,请稍侯......
精彩评论