What does <%== %> do in rails erb?

后端 未结 2 937
长情又很酷
长情又很酷 2020-12-02 14:36

I saw this recently, thought it was interesting. But I don\'t really understand what it does?

Ex. I have a rails app and I want to bootstrap some json, so that I d

2条回答
  •  醉梦人生
    2020-12-02 14:42

    <%== is equivalent to raw.

    From the Ruby on Rails Guide:

    To insert something verbatim use the raw helper rather than calling html_safe:

    <%= raw @cms.current_template %> <%# inserts @cms.current_template as is %>
    

    or, equivalently, use <%==:

    <%== @cms.current_template %> <%# inserts @cms.current_template as is %>
    

提交回复
热议问题