Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add "data-main" attribute to a script tag using rails javascript helpers?

Require-js commonly uses an attribute called "data-main" on the script tag. Is there a way to tell Rails' javascript tag helpers to add it, or should I just do it the old-fashioned way?

like image 988
egervari Avatar asked Dec 16 '22 14:12

egervari


1 Answers

<%= javascript_include_tag 'application', :'data-main' => 42 %>

renders as :

<script data-main="42" src="/javascripts/application.js?1301333790" type="text/javascript"></script>

like image 119
kares Avatar answered May 01 '23 13:05

kares