Skip to content


Subversion checkout URL

You can clone with
Download ZIP


class-attribute is reordered when using .foo and (class="foo") #306

sirlantis opened this Issue · 1 comment

2 participants


I was confused by this output when I tried to use jquery-tmpl conditions in the class:

# .a(class="{{if x}}{{/if}}")'.a(class="{{if x}}{{/if}}")').to_html
#=> "<div class='a x}}{{/if}} {{if'></div>\n"

# %div(class="a {{if x}}{{/if}}")'%div(class="a {{if x}}{{/if}}")').to_html
#=> "<div class='a {{if x}}{{/if}}'></div>\n"

The current behavior prevents duplicate classes (.foo(class="foo")) but it would be better just to leave the class-attribute order untouched.


I'm tentatively okay with this, but it's important that the classes are emitted in a deterministic order for testing purposes. Internally, Haml does array1 | array2 to ensure uniqueness of classes; if you can show that this maintains a deterministic order back through Ruby 1.8.6 I'll remove the sorting.

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.