k0kubun / hamlit

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

Overriding "class" in a div doesn't work #116

Closed andrewfader closed 6 years ago

andrewfader commented 6 years ago

I'm doing something like this

%div.price{class: song.up_or_down?}

It works fine in vanilla haml, but in hamlit it instead returns some number for the method (should return a string)

k0kubun commented 6 years ago

It's not reproductive:

$ ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]

$ hamlit version
2.8.4

$ cat in.haml
- song = Object.new
- def song.up_or_down?; true; end
%div.price{class: song.up_or_down?}

$ hamlit in.haml
<div class='price true'></div>

Could you see https://github.com/k0kubun/hamlit#reporting-an-issue and provide mode details?

andrewfader commented 6 years ago

Make your file return a string and it produces this

$  ruby -v  
ruby 2.5.0preview1 (2017-10-10 trunk 60153) [x86_64-linux]

$ hamlit version
2.8.4

$ cat test.haml 
- song = Object.new
- def song.up_or_down?; "hello"; end
%div.price{class: song.up_or_down?}
 $  hamlit test.haml 
<div class='20641625616 price'></div>
k0kubun commented 6 years ago

Thanks for details.

As it's fixed on master branch (but not released because there are still other problems with 2.5), I'll release next version for you.

k0kubun commented 6 years ago

Done.

$ ruby -v
ruby 2.5.0preview1 (2017-10-10 trunk 60153) [x86_64-darwin16]

$ hamlit version
2.8.5

$ cat test.haml
- song = Object.new
- def song.up_or_down?; "hello"; end
%div.price{class: song.up_or_down?}

$ hamlit test.haml
<div class='hello price'></div>
andrewfader commented 6 years ago

Thanks! 👍