Skip to content


Subversion checkout URL

You can clone with
Download ZIP


doesn't support quoted symbols #43

aaronjensen opened this Issue · 5 comments

2 participants

.whatever { data: { :'some-thing' => 'foo' } }

Parses as

      $o.push("<div class='whatever'>{ data: { :'some-thing' => 'foo' } }</div>");

As far as I can tell, it's not possible to use dashes in any way. strings don't work on the left hand side either.


There are two things I can spot in your Haml:

  1. The attributes hash must directly follow the element/id/class name.
  2. You can't mix Ruby 1.8 and 1.9 style within the same attribute.

Testing it in the console looks fine:

» coffee
coffee> hc = require 'haml-coffee'
{ compile: [Function],
  template: [Function] }
coffee> hc.compile('.whatever{ data: { some-test: "test" } }')()
'<div class=\'whatever\' data-some-test=\'test\'></div>'
coffee> hc.compile('.whatever{ :data => { :some-test => "test" } }')()
'<div class=\'whatever\' data-some-test=\'test\'></div>'

I looks like quoting data attributes does indeed not work as intended:

coffee> hc.compile(".whatever{ data: { 'some-test': 'test' } }")()
'<div class=\'whatever\' data-\'some-test\'=\'test\'></div>'
coffee> hc.compile(".whatever{ data: { \"some-test\": 'test' } }")()
'<div class=\'whatever\' data-"some-test"=\'test\'></div>'

but it works fine for non-data attributes:

coffee> hc.compile(".whatever{ \"some-test\": 'test' }")()
'<div class=\'whatever\' some-test=\'test\'></div>'
coffee> hc.compile(".whatever{ 'some-test': 'test' }")()
'<div class=\'whatever\' some-test=\'test\'></div>'

I'll fix these on Monday. Thanks for reporting.


I typo'd the space, that wasn't actually there.

  1. It's odd that I can choose to not quote them. does that work in haml? it certainly doesn't work in ruby
  2. Why can't I combine the two syntaxes? I can in ruby. Does it not work in haml?

I tested in haml, I can combine syntaxes and i cannot use unquoted some-test


I didn't know that Ruby style attributes can be mixed actually. I'll have a look if I can change that and still can parse inline CoffeeScript code safely.

Just pushed a fix for the attribute quote problem to haml-coffee.


So mixing 1.8 and 1.9 attribute style is now possible in haml-coffee.

@netzpirat netzpirat closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.