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 <
to replace <
if it is just plain html
You shouldn't write <
directly into markup, use <
, >
, etc.
精彩评论