@**
 * Javascript CommonJS module loader
 *
 * Should only be used in development mode: in production, compiled Javascript should be used
 *@
@* TODO: Remove the dependency to jQuery? *@
@()(implicit request: play.api.mvc.RequestHeader)

@script(Symbol("type") -> "text/javascript") {
var require = function(moduleName) {
  var body = "";
  $.ajax({
    url: "/assets/javascripts/" + moduleName + ".js",
    dataType: "text", async: false,
    success: function(result) { body = result; }
  });
  body = "var exports = {};\n" + body + "\nreturn exports;";
  var fnct = new Function("module", "exports", body);
  return fnct();
}
}