Rails ERB<%-...-%>与<%...%> [英] Rails ERB <%- ... -%> vs. <% ... %>

查看:74
本文介绍了Rails ERB<%-...-%>与<%...%>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

因此,对于ERB文件,<%之间有什么区别-...-%>与<%...%>?据我所知,它们的作用相同,但是一个需要比另一个更多。

So for an ERB file, what's the difference between <%- ... -%> vs. <% ... %>? As far as I can tell, they serve the same purpose but one requires more typing than the other.

推荐答案

使用破折号可以删除在ERB标签周围的空白处,有一个 RailsCast 对此进行了讨论其他查看技巧。

Using the dash removes the whitespace around the ERB tag, there is a RailsCast that talks about this and some other View tricks.

这篇关于Rails ERB&lt;%-...-%&gt;与&lt;%...%&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆