Yeah, I am playing around with RequireJS. I use StealJS in pretty much
all of my projects, but I want to play "outside the box" a
little here.
I don't remember where I found this, but I have been playing
with the following which works, but using "load" gives the
following warning:
Synchronous XMLHttpRequest on the main thread is deprecated because
of its detrimental effects to the end user's experience. For more
help, check http://xhr.spec.whatwg.org/.
I'm wondering if this is only a development thing and once the
templates are compiled for production, this will go away.
-
define(function() {'use strict';var Mustache = {},buildMap = {};Mustache.load = function(name, parentRequire, load, config) {var path = parentRequire.toUrl(name + '.mustache');if(config.isBuild) {var compiler = require.nodeRequire('can-compile');compiler.compile(path, function(error, output) {buildMap[name] = output;load(output);});}else {parentRequire(['can/view/mustache'], function(can) {load(function(data, helpers){return can.view(path, data, helpers);});});}};Mustache.write = function (pluginName, name, write) {if (buildMap.hasOwnProperty(name)) {var text = buildMap[name];write.asModule(pluginName + "!" + name, text);}};return Mustache;});










