[英]How do i write my erb file without skipping lines
i have the t function witch return some text. 我有t函数巫婆返回一些文字。
so on my erb file i have something like that: 所以我的erb文件我有类似的东西:
<%= t 'content1' %>
<%= t 'content2' %>
and the html output is something like that: 并且html输出是这样的:
"text of the content 1"
"text of the content 2"
I would like to output something like that: 我想输出类似的东西:
"text of the content 1" "text of the content 2"
thanx 感谢名单
ERB has an option in the closing tag whether to have a newline after it. ERB在结束标记中有一个选项,是否在其后面有换行符。 Just add a dash: 只需添加一个破折号:
<%= t 'content1' -%>
<%= t 'content2' %>
Erb is a little overrated compared to other template languages out there. 与其他模板语言相比,Erb有点过高。 But, the good thing is it allows you to control the output. 但是,好处是它允许您控制输出。 As @DMG pointed out add a '-' to your tags but there is also another point I wanted to show. 正如@DMG所指出的那样,在你的标签上添加一个' - ',但我还想表明另一点。
<%- method(...) -%>
Will not show any lines on output. 不会在输出上显示任何行。 While this will create a blank line: 虽然这会创建一个空行:
<% method(...) -%>
Just something to keep in mind if your writing templates for scripts, unit tests, rake task, or anything else outside of Rails/ActionView 如果您编写脚本,单元测试,rake任务或Rails / ActionView之外的任何其他内容,请记住一些事项
做就是了:
<%= "#{t('content1')}#{t('content2')}" %>
<%= "#{t('content1')} #{t('content2')}" %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.