Search code examples
ruby-on-railsrubyhamlspree

String interpolation trouble with Haml and Spree


I'm trying to convert my Spree store to Haml, and I'm facing some trouble with some parts of the backend. For instance, I take the following Haml code:

- @orders.each do |order|   
  %tr{:class => "state-#{order.state.downcase} #{cycle('odd', 'even')}"}   
  %tr{:class => "state-#{order.state.downcase}"}

And here's the output HTML (simplified to a single iteration):

<tr class="state-#order.state.downcase"></tr>
<tr></tr>

Can someone help me understand why the string interpolation is wrong in both cases? I have been looking at this for hours...


Solution

  • I have just revisited this and came across the fact that Deface (used by Spree) is not compatible with Haml.

    So either one uses ERB and lives with it, or completely disables Deface and rewrite all 'defaced' views.

    P.S.: In order to disable Deface, I added config.deface.enabled = false to development.rb, production.rb and test.rb inside config/environments/.