[英]Ruby on Rails: How do you display “raw” erb tags in views?
For example, I want to display <%= @location.country %>
in views to the user. 例如,我想在视图中向用户显示
<%= @location.country %>
。 So if the user visits http://domain.com/tutorials/123 , he'll see <%= @location.country %>
. 因此,如果用户访问http://domain.com/tutorials/123 ,他会看到
<%= @location.country %>
。 That is, Rails doesn't process that portion. 也就是说,Rails不处理该部分。
I'm thinking something along the lines of <*= @location.country %>
, but of course that doesn't work. 我正在考虑
<*= @location.country %>
,但当然这不起作用。 Any ideas? 有任何想法吗?
你添加第二个%。
<%%= @location.country %>
You need to use html entities for the <
( <
) and >
( >
). 您需要为
<
( <
)和>
( >
)使用html实体。 So something like <%= @location.country %>
所以类似于
<%= @location.country %>
will work. 将工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.