代码之家  ›  专栏  ›  技术社区  ›  christophercotton

如何使用Rails 3停止<%=strings%>的自动编码

  •  4
  • christophercotton  · 技术社区  · 16 年前

    <%= "string with unsafe characters' like <" %>
    

    它将自动编码为:

    string with unsafe characters&quot; like &amp;
    

    <%=h "string with unsafe characters' like <" %>
    

    我怎么才能让它停下来?我已经存储了一些短的JavaScript,我需要插入到模板中,而不需要它自动编码字符串?

    1 回复  |  直到 15 年前
        1
  •  10
  •   Jakub Hampl    16 年前

    raw 方法如下:

    <%=raw "string with unsafe characters' like <" %>