开发者

How to write "<%" in a erb file

I have an .erb file where I'd like to return the following text:

Name <%r>

When I rend开发者_StackOverflower this file, the erb interprets the <% as a ruby code and doesn't render the % signal.

I found one way to do this, putting the % signal in a String like this:

Name <<%= "%" %>r>

But this is very ugly. Is there any other way to do it?


I believe you are looking for double percents

<%%r%>

This is used extensively when using erb templates to generate erb templates.

update

<%%r>


you could use &lt; to replace < if it is just plain html


You shouldn't write < directly into markup, use &lt;, &gt;, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜