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

Weird behavior when using space before the : of an attribute #56

Closed
Sephi-Chan opened this issue Jul 12, 2012 · 2 comments
Closed

Weird behavior when using space before the : of an attribute #56

Sephi-Chan opened this issue Jul 12, 2012 · 2 comments

Comments

@Sephi-Chan
Copy link

I noticed some strange behaviors when using a space between an attribute and its :.

/ Works well.
%span.value{ 'foo': 'foo', 'bar': 'bar', baz: 'baz' } Foo
/ <span class="value" foo="foo" bar="bar" baz="baz">Foo</span>

/ Throws error. ExecJS::ProgramError: Unable to parse tag.
/ %span.value{ 'foo' : 'foo', 'bar' : 'bar', baz: 'baz' } Foo
/ It only throw error when the space is after the first attribute !?


/ Works weird: no error despite the space but fucked HTML.
%span.value{ 'foo': 'foo', 'bar' : 'bar', baz: 'baz' } Foo
/ <span class="value" foo="foo&quot;, &quot;bar&quot; :&quot;bar" baz="baz">Foo</span>

/ Less strange in data attribute: the attribute is just not displayed:
%span.value{ data: { 'foo' : 'foo', 'bar': 'bar' } } Foo
/ <span class="value" data-bar="bar">Foo</span>

So I stick with foo: 'foo' or 'foo-foo': 'foo' for keys.
But I thought it was important to point that bugs out as they can drive you crazy.

@netzpirat
Copy link
Collaborator

The attribute parser is currently expecting the HAML Ruby 1.9 style tags to be in the strict format of { attr: value }, but it allows also (in contrast to the original HAML implementation) JSON style quoted attributes with either single or double quoutes: { 'attr': value } or { "attr": value }, and there must be no space in between the attribute name and the colon.

I'm currently in holiday mode, so I won't be able to have a closer look within the next two weeks, but it might be easily possible to extend the attribute parser to be fully JSON compatible. Thanks for reporting, I'll update the issue when I returned.

@netzpirat
Copy link
Collaborator

Just did a quick test and I found the bug to be fixed very easily. Haml_Coffee_Assets version 1.2.0 supports now all the reported JSON style attributes.

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