Created
September 5, 2012 10:18
-
-
Save wayneashleyberry/3634563 to your computer and use it in GitHub Desktop.
bootstrap data for require.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- require --> | |
| <script data-main="/js/main" src="/js/vendor/require-2.0.6.js"></script> | |
| <!-- data --> | |
| <script> | |
| define('data', [], function () { | |
| return <?= json_encode($bootstrap); ?>; | |
| }); | |
| </script> |
Look...I'm tired ok!
From twitter you mentioned you want to wrap require so that it is not visible but define() is. You can always manually remove them:
<script src="require.js"></script>
<script>requirejs = require = undefined;</script>If you are delivering a bundled build, that includes requirejs in it, you can use the wrap r.js optimizer options to put a function wrapper around the code, and in the wrap.endFile, do a window.define = define right before the end of the closure (or pass a global into the closure created by wrap.startFile and endFile).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
define("define", [], function() { return require("define"); }); // require("define").define.define.define.define.define...