pablof7z / chardin.js

Simple overlay instructions for your apps.

Home Page:https://heelhook.github.io/chardin.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Attribute 'data-intro' and 'data-position' doesn't work in Rails ERb link_to method

hachi8833 opened this issue · comments

Hello,

I found that my sweet charding.js causes an error in Rails when the attribute data-intro and data-position are added to Rails ERB method like link_to as:

<%= link_to "Home", root_path, class: 'brand' data-intro: 'Goes back to Home page.'%>

The root cause is clear that Ruby is unable to handle hyphen in a symbol name.

I just fixed chardin.js to change data-intro and data-position to data_intro and data_position to workaround the issue.

I hope the creator would apply the fix to the source some day.

Best regards,

True! I also ran into this. The solution that Hachi outlines would definitely solve this.

Try:

<%= link_to "Home", root_path, class: 'brand', data: { intro: 'Goes back to Home page.'} %>

Rails will add the hyphen for you and you won't need to modify chardin.js

Yeah, like @msmithstubbs says, you can do that or you can simply use a string for the hash key:

<%= link_to "Home", root_path, class: 'brand', "data-intro" => 'Goes back to Home page.'%>