k0kubun / hamlit

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

update test name and add test for haml compatibility #88

Closed shmargum closed 8 years ago

shmargum commented 8 years ago

would it also be possible to use the global configuration option for escape_html instead of having to use the Hamlit::Utils.escape_html method?

k0kubun commented 8 years ago

While the tested behavior is compatible with haml, this spec has nothing to do with plain filter. Plain filter's feature and escape method's behavior are independent and I couldn't understand why this spec is necessary. So this PR isn't acceptable.

would it also be possible to use the global configuration option for escape_html instead of having to use the Hamlit::Utils.escape_html method?

There is already escape_html option and it works. For your usecase, following template is enough.

input

<script>
#{'<script>'}

output

Hamlit::Engine.options[:escape_html] = escape_html
eval Hamlit::Engine.new.call("<script>\n\#{'<script>'}")

escape_html = false

<script>
<script>

escape_html = true

<script>
&lt;script&gt;
k0kubun commented 8 years ago

Added option to test it in master. https://github.com/k0kubun/hamlit/commit/89a58078470c7949f4078fb5442a4fed3f3828de Please check the compatibility in the following way.

example

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

$ haml -t ugly in.haml                                                                 
<script>
<script>

$ bundle exec hamlit render --escape-html=false in.haml                                      
<script>
<script>

$ haml -t ugly -e in.haml                                                   
<script>
&lt;script&gt;

$ bundle exec hamlit render --escape-html=true in.haml                             
<script>
&lt;script&gt;