How do I escape the ERB tag in ERB

自闭症网瘾萝莉.ら 提交于 2019-11-26 19:07:04

问题


I have a simple fixture.yml file:

label:
    body: "<%= variable %>"

The issue is that the ERB code is parsed as part of loading the fixture, whereas I actually want the body to be literally "<%= variable %>" (un-interpolated).

How do I escape the ERB tag?


回答1:


Add a second % to the opening tag:

label:
    body: "<%%= variable %>"

The <%% sequence is valid ERB, rendered as a literal <%.



来源:https://stackoverflow.com/questions/2322413/how-do-i-escape-the-erb-tag-in-erb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!