Add a form of static:require_module that assumes that the factory is self-initializing

This commit is contained in:
Calen Pennington
2017-12-21 15:29:53 -05:00
parent 7858066776
commit bacd4334ed
5 changed files with 64 additions and 3 deletions

View File

@@ -0,0 +1,27 @@
define([], function() {
'use strict';
return function invokePageFactory(name, factory) {
var args;
if (typeof window.pageFactoryArguments === 'undefined') {
throw Error(
'window.pageFactoryArguments must be initialized before calling invokePageFactory(' +
name +
'). Use the <%static:require_page> template tag.'
);
}
args = window.pageFactoryArguments[name];
if (typeof args === 'undefined') {
throw Error(
'window.pageFactoryArguments["' +
name +
'"] must be initialized before calling invokePageFactory(' +
name +
'). Use the <%static:require_page> template tag.'
);
}
factory.apply(null, window.pageFactoryArguments[name]);
};
});