">...">

Rails + Haml: how to parameter unescape tag?

I am trying to execute the following content in the source code:

<div id="box<%=id%>"></div>

Without any sign in Haml.

%div{ :id => "box_<%=id%>" }

produces

<div id='box_&lt;%=id%&gt;'></div>

Currently, the only way I can do this with Haml is to use a filter :plainand hardcode HTML without using any viewing helpers. How can i fix this?

I need this because I am forced to follow this convention due to a third-party syntax convention: JavaScript JavaScript Templates

Link:

Haml Link

+5
source share
3 answers

You say you code in Haml, but Erb is indicated in parentheses.

  • 1. Ruby:

    %div{ :id => "box_#{id}" }
    
  • 2. 2.

. , JS. , , .

+4

, HAML . , , - HAML :

%script#template(type="text/html")
    %div{ :id => "box_<%=id%>" }

:

%script#template(type="text/html")
    <div id="box_<%=id%>"></div>

script HAML, , %, # .., , , , , . , , jQote ( , Javascript templating) % $ Javascript head :

%script( type="text/javascript")
    $(function() { $.jqotetag( '$' ); });

, % Ruby. , :

%script#template(type="text/html")
    <div id="box_<$=id$>"></div>

!

+2
0

All Articles