views:

96

answers:

3

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

Name <%r>

When I render 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?

+3  A: 

I believe you are looking for double percents

<%%r%>

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

update

<%%r>
jrhicks
Your code outputs <%r%>, he wanted just <%r>
Ryan Bigg
A: 

you could use "& lt;" (without the space) to replace < if it is just plain html

Ed
In StackOverflow, you can surround stuff with <code> to escape and keep from having to put a space.
jrhicks
A: 

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

thenduks