MtHaml icon indicating copy to clipboard operation
MtHaml copied to clipboard

Interpolation in filters should not be escaped

Open weotch opened this issue 8 years ago • 1 comments

From the HAML docs:

Currently, filters ignore the :escape_html option. This means that #{} interpolation within filters is never HTML-escaped.

Currently, in MtHaml, this...

:php
  $code = "var msg='hi';";
:javascript
  #{$code}

Results in:

<script type="text/javascript">
//<![CDATA[
   var msg=&#039;hi&#039;;  
//]]>
</script>

It should be:

<script type="text/javascript">
//<![CDATA[
   var msg='hi';  
//]]>
</script>

weotch avatar Jul 05 '16 17:07 weotch

As a workaround, you can do:

:php
  $code = "var msg='hi';";
%script(type="text/javascript")
  :plain
    // Other JS code
  :php
    echo $code;
  :plain
    // More JS code

weotch avatar Jul 05 '16 18:07 weotch