nex3/haml — Issue #478: Replace underscores in HTML5 data attribute names with hyphens
Author: codyrobbins
Created: 2012-01-12 03:18:36+00:00
State: open

This is a feature request rather than a bug.

The example

%a{:href=>"/posts", :data => {:author_id => 123}} Posts By Author

given in the reference produces

Posts By Author

This markup is hideously ugly with the underscore—the data attribute should be named `data-author-id`. Since HAML isn’t substituting hyphens for the underscores automatically, there doesn’t really seem to be any advantage to using the special `:data` attribute key over just doing

%a{:href=>"/posts", 'data-author-id' => 123} Posts By Author

Using the `:data` key is more typing and you still end up having a string hash key for the attribute anyways:

%a{:href=>"/posts", :data => {'author-id' => 123}} Posts By Author

What’s the point?