k0kubun / hamlit

High Performance Haml Implementation
https://rubygems.org/gems/hamlit
Other
981 stars 59 forks source link

don't escape the plain filter #87

Closed shmargum closed 8 years ago

shmargum commented 8 years ago

This isn't the biggest deal, but haml doesn't escape interpolated code in the :plain filter This caused some differences when porting I of course can add a .html_safe to the interpolated code, but I figured I'd submit a PR anyway. I know that the defaults for hamlit are to escape code, but since there is a skipped haml test for this I figured I'd submit a PR making the change.

I was not able to get around having to add the html_safe to the interpolated code by adding to my config: Hamlit::RailsTemplate.set_options html_safe: false

k0kubun commented 8 years ago

It was incompatibility that should be fixed. Thank you!

WaKeMaTTa commented 8 years ago

The Engine options need to be changed from:

Option Default Feature
escape_html true HTML-escape for Ruby script and interpolation. This is false in Haml.

To:

Option Default Feature
escape_html false HTML-escape for Ruby script and interpolation.

or not? :question:

k0kubun commented 8 years ago

Why do you think so? Hamlit aims to be compatible with Haml when the options are the same, not with default Haml's behavior. Since I recommend all people to use escape_html: true, I intentionally specified that default option.

WaKeMaTTa commented 8 years ago

Because of this https://github.com/k0kubun/hamlit/pull/87/files#diff-e6a59e52cce4b06965acdd39110509c1R21

k0kubun commented 8 years ago

The behavior is not related to escape_html option at all.

$ cat in.haml 
:plain
  <script>
  #{'<script>'}

$ haml in.haml
<script>
<script>

$ haml -e in.haml
<script>
<script>
WaKeMaTTa commented 8 years ago

Right, my mistake :+1: