Skip to content

Instantly share code, notes, and snippets.

@luozhihua
Created October 23, 2013 09:16
Show Gist options
  • Save luozhihua/7115289 to your computer and use it in GitHub Desktop.
Save luozhihua/7115289 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
</body>
</html>
var ogle = (function() {
function Ogle(){}
var modules = {};
Ogle.prototype = {
define: function(key, func){
modules[key] = func;
},
require: function(key, func) {
var module = modules[key],
props = {},
o = new Ogle();
module(props);
for (var k in props) {
o[k] = props[k];
}
func(o);
}
};
var a = new Ogle();
a.constructor = null;
return a;
}());
ogle.define('tools', function(exports){
exports.log = function(m){
console.log('> '+ m);
};
});
ogle.require('tools', function(o){
o.log('Hello Ogle!');
o.log(o.a);
});
ogle.log();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment