Reputation: 7045
I want to print following as a string in my .html.erb
view.
<%= selected_color %>
So, I tried following in my file:
<h3><%= '<%= selected_color %>' %></h3>
It gave me following error:
syntax error, unexpected $undefined, expecting ')'
If I remove <%= '<%= selected_color %>' %>
and place some string like abc
, then it is printed on page without any issue.
As it is static page, I don't want to create a controller for it. So, can you help in showing that string on page?
p.s. I'm using ruby v1.9.3 and rails v3.1.0
Upvotes: 7
Views: 1899
Reputation: 1116
You should double the %
symbols as follow:
<h3><%%= rating_color %></h3>
In erb.rb line 50, we see that <%%
is a special tag that is replaced by <%
we can also see that on line 650.
Upvotes: 9
Reputation: 1318
Pure HTML
<%= selected_color %>
or double % as mentioned by @ex0ns
<%%= selected_color %>
Upvotes: 3