【问题标题】:RoR: Parsing html &lt; into < and other similar HTML to literalsRoR:将 html < 解析为 < 和其他类似的 HTML 到文字
【发布时间】:2010-11-25 00:58:08
【问题描述】:

我正在使用 GCal4Ruby gems 插件。

我正试图让它呈现一个嵌入式谷歌日历。

所以相关的方法就是这里描述的to_iframe:

http://cookingandcoding.com/docs/gcal4ruby/classes/GCal4Ruby/Service.html

当我调用该方法时,它会产生:

图一

<iframe src ="relevant_and_working_Gcal_URL" width="100%" height="300">
  text here
</iframe>"

在页面中显示为文本,这是我想要的,但查看它呈现为的源:

图2:

&lt;iframe src ="relevant_and_working_Gcal_URL" width="100%" height="300"&gt;
  text here
&lt;/iframe&gt;

所以我的问题是有没有任何 ruby​​ 方法可以接受字符串参数并进行相关替换?

也就是说,它将接受字符串图2并返回图1中的字符串。

我会在一两个小时后回来发布一个确切的例子。

【问题讨论】:

    标签: html ruby-on-rails iframe rubygems


    【解决方案1】:

    如果您使用的是 Rails 3,请使用 raw 方法输出原始 html。

    <%= raw @service.to_iframe %>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-20
      • 1970-01-01
      • 2011-09-08
      • 2013-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多