开发者

How to write "<%" in a erb file

开发者 https://www.devze.com 2022-12-09 14:22 出处:网络
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 % sign

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

精彩评论

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