Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpolation in filters should not be escaped #95

Open
weotch opened this issue Jul 5, 2016 · 1 comment
Open

Interpolation in filters should not be escaped #95

weotch opened this issue Jul 5, 2016 · 1 comment

Comments

@weotch
Copy link
Contributor

weotch commented Jul 5, 2016

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
Copy link
Contributor Author

weotch commented Jul 5, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant