HTML5 Data Attributes

Here's a proposed patch to simplify HTML5 data attribute declaration:

Any comments?

As explained in the ticket:

Specifying HTML5 data attributes for tags could be more streamlined. Right now you would use string keys and repetition.

To create, for example, this:

<div class="user" data- location="{&quot;city&quot;:&quot;Chicago&quot;,&quot;state&quot;:&quot;Illinois&quot;}" data-name="Stephen" id="user_1">

You would do something like this:

div_for user, 'data-name' =>, 'data-location' => { city:, state: user.state }.to_json do # ...

Here's a proposed simplification, using a single "data" node to define the attributes:

div_for user, data: { name:, location: { city:, state: user.state } } do # ...

Seeing as data attributes are accessed primarily by JavaScript (with libraries like jQuery already interpreting embedded JSON objects), it makes sense to convert objects to JSON automatically rather than create pseudo-nested attributes like "data-location-city" and "data- location-state".