Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Support for setting a root for requires. #1

Merged
merged 1 commit into from

2 participants

@wagenet
Collaborator

Useful if you're doing many requires in the same directory.

@wagenet
Collaborator

This also prevents multiple reloads in cases where nothing is returned from a minispade module.

@wycats wycats merged commit e660d0e into wycats:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 18, 2011
  1. @wagenet

    Support for setting a root for requires. Useful if you're doing many …

    wagenet authored
    …requires in the same directory.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/main.js
View
11 lib/main.js
@@ -1,6 +1,7 @@
if (typeof document !== "undefined") {
(function() {
minispade = {
+ root: null,
modules: {},
loaded: {},
@@ -10,10 +11,14 @@ if (typeof document !== "undefined") {
if (!loaded) {
if (mod) {
- loaded = mod();
+ loaded = mod() || true;
minispade.loaded[name] = loaded;
} else {
- throw "The module '" + name + "' could not be found";
+ if (minispade.root && name.substr(0,minispade.root.length) !== minispade.root) {
+ return minispade.require(minispade.root+name);
+ } else {
+ throw "The module '" + name + "' could not be found";
+ }
}
}
@@ -35,4 +40,4 @@ if (typeof document !== "undefined") {
}
});
})();
-}
+}
Something went wrong with that request. Please try again.