requirejs-rails
requirejs-rails copied to clipboard
Allow defining functions in requirejs.yml
Some RequireJS config options such as init need a function, however YAML and JSON can only store data - not JavaScript. As a workaround this detects a function and unescapes it when the config is added to the page in the helper.
Fixes #177
@wuservices Could you provide an example?
See #177.
Example:
shim:
underscore:
exports: _
init: |
function() {
this._.templateSettings.interpolate = /\{\{(.+?)\}\}/g;
}
twitter/bootstrap/button:
deps: [jquery]
# Reverts $.fn.button to jQuery UI btn and
# assigns Bootstrap button functionality to $.fn.btn
init: |
function($) {
var btn = $.fn.button.noConflict();
$.fn.btn = btn;
}
+1
+1 @carsomyr any reason why this can't be merged in? Would be nice to have!