Merge pull request #17316 from cpennington/switch-cms-login-to-webpack

Migrate login.js to webpack
This commit is contained in:
Calen Pennington
2018-01-30 14:24:08 -05:00
committed by GitHub
10 changed files with 57 additions and 59 deletions

View File

@@ -154,7 +154,7 @@ source, template_path = Loader(engine).load_template_source(path)
</script>
</%def>
<%def name="require_page(page_name, class_name)">
<%def name="invoke_page_bundle(page_name, class_name)">
<%doc>
Loads Javascript onto your page synchronously.
Uses RequireJS in development and a plain script tag in production.
@@ -174,14 +174,7 @@ source, template_path = Loader(engine).load_template_source(path)
pageFactoryArguments['${class_name | n, js_escaped_string}'] = [];
% endif
</script>
% if not settings.REQUIRE_DEBUG:
<script type="text/javascript" src="${staticfiles_storage.url(page_name + '.js') + '?raw'}"></script>
% endif
<script type="text/javascript">
(function (require) {
require(['${page_name | n, js_escaped_string}']);
}).call(this, require || RequireJS.require);
</script>
<%self:webpack entry="${page_name}"/>
</%def>
<%def name="require_module(module_name, class_name)">

View File

@@ -8,7 +8,7 @@ define([], function() {
throw Error(
'window.pageFactoryArguments must be initialized before calling invokePageFactory(' +
name +
'). Use the <%static:require_page> template tag.'
'). Use the <%static:invoke_page_bundle> template tag.'
);
}
args = window.pageFactoryArguments[name];
@@ -19,7 +19,7 @@ define([], function() {
name +
'"] must be initialized before calling invokePageFactory(' +
name +
'). Use the <%static:require_page> template tag.'
'). Use the <%static:invoke_page_bundle> template tag.'
);
}
factory.apply(null, window.pageFactoryArguments[name]);

View File

@@ -52,8 +52,8 @@ from openedx.core.djangolib.js_utils import js_escaped_string
</div>
</%block>
<%block name="requirejs_page">
<%static:require_page page_name="js/pages/login" class_name="LoginFactory">
<%block name="page_bundle">
<%static:invoke_page_bundle page_name="js/pages/login" class_name="LoginFactory">
"${reverse('homepage') | n, js_escaped_string}"
</%static:require_page>
</%static:invoke_page_bundle>
</%block>