sstephenson/sprockets — Issue #301: Wrapping Requires in Anonymous Function
Author: pwim
Created: 2012-03-02 08:42:15+00:00
State: open

I'm developing a JavaScript widget as described in:

http://www.doorkeeperhq.com/developer/embeddable-javascript-widget

I'd like to wrap all my JavaScript in an anonymous function and immediately execute it like this to avoid polluting the namespace:

(function() {
//= require getElementsByClassName-1.0.1
//= require ready
//= require_tree ./widget
})()

But if I do this, sprockets won't embed my javascript/coffeescript files, as the first line isn't a magic comment. Is there a work around, or do I need to concat these files by hand?