如何解决显示带有特殊字符代码的html,只需将其用作html即可
|| 我在我的erb文件之一中使用以下行:<%=@map.div(:width => 800,:height => 500)%>
它输出以下HTML:
<div id=\"map\" style=\"width:800px;height:500px\" ></div>
显示为:<div id=\"map\" style=\"width:800px;height:500px\" ></div>
在浏览器中。
编辑:我唯一的另一段代码是:
require \'rubygems\'
include GeoKit::Geocoders
class HomeController < ApplicationController
def index
coordinates =[13.0343841,80.2502535] #you can get the coordinates for the location you want from http://stevemorse.org/jcal/latlon.php
@map = GMap.new(\'map\')
@map.control_init(:large_map => true,:map_type => true)
@map.center_zoom_init(coordinates,10) # here 10 referes to the zoom level for a map
@map.overlay_init(GMarker.new(coordinates,:title => \'Chennai\',:info_window => \'Chennai\'))
end
end
为什么这样做呢?如何防止Rails 3将我的代码转换为特殊字符?
解决方法
据我们对
div
方法一无所知,您可以尝试一下
<%= @map.div(:width => 800,:height => 500).html_safe %>
最好以div
方法将html_safe
添加到输出中
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。