#ERB #HAML #HTML: HTML5 data- attributes using RESTful approach for rails / sinatra
<!--
HTML5 data- attributes using RESTful approach
HTML5 specifies extensible attributes like data-foo=“bar” (or as in Twitter Bootstrap data-toggle=“modal”), which poses two problems for Rails.
First, if you’re using symbol notation in link_to (for instance) to specify attributes, this fails (dash is not a valid symbol character), so:
-->
<% link_to('Edit', '../main.html', :class => "btn", :data-toggle => "modal") %> <!-- INVALID!! -->
<!--
There are two solutions:
1. put the symbols in quotes,
2. use the special ":data" hash
-->
<% link_to('Edit', '../main.html', :class => "btn", :'data-toggle' => "modal") %> <!-- SOLUTION 1 -->
<% link_to('Edit', '../main.html', :class => "btn", :data{:toggle => "modal"}) %> <!-- SOLUTION 2 -->
<!-- Credit goes to: To Harrison JR (http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to#1286-HTML5-data-attributes-using-RESTful-approach) -->