Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doesn't support quoted symbols #43

Closed
aaronjensen opened this issue May 18, 2012 · 5 comments
Closed

doesn't support quoted symbols #43

aaronjensen opened this issue May 18, 2012 · 5 comments

Comments

@aaronjensen
Copy link

.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.

@netzpirat
Copy link
Collaborator

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.

@aaronjensen
Copy link
Author

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?

@aaronjensen
Copy link
Author

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

@netzpirat
Copy link
Collaborator

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.

@netzpirat
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants