update require

This commit is contained in:
afc163 2015-11-28 16:34:20 +08:00
parent a0f93bfa83
commit f162e13d6b
2 changed files with 7 additions and 23 deletions

View File

@ -1,3 +1,10 @@
window.require = function(path) {
if (path in window) {
return window[path];
} else {
throw 'There should not have modules here: ' + path;
}
};
window['css-animation'] = require('css-animation');
window['react-router'] = require('react-router');
window.Clip = require('./clip');

View File

@ -46,29 +46,6 @@
};
</script>
<script src="{{static_url('../dist/demo.js')}}"></script>
<script>
window.require = function (path) {
var result = window;
var namespaces = path.split('/');
namespaces.forEach(function (key, i) {
if (i === 2) {
key = capitalizeFirstLetter(key);
}
if (key !== 'lib') {
if (result[key]) {
result = result[key];
} else {
throw 'There should not have modules here 2.';
}
}
});
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
return result;
};
</script>
<script src="https://t.alipayobjects.com/images/T1DrxhXe0mXXXXXXXX.js"></script>
{% block scripts %}{% endblock %}
</head>