开发者

Display the html with special character code intead of just using it as html

I am using the following line in one of my erb files :

<%=@map.div(:width => 800, :height => 500)%>

it output the following HTML :

&lt;div id="map" style="width:800px;height:500px" &gt;&lt;/div&gt;

Displayed as : <div id="map" style="width:800px;height:500px" ></div>

in the browser.

EDIT : My only other piece of code is :

    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, :开发者_StackOverflow社区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

Why is it doing it? How can I prevent rails 3 to translate my code in special char?


As far as we didn't know anything about div method you can try this

<%= @map.div(:width => 800, :height => 500).html_safe %>

Better to add html_safe to output in div method

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜