Skip to content
Snippets Groups Projects
Commit 85a375a3 authored by Calen Pennington's avatar Calen Pennington
Browse files

Add webpack assets directly to xmodule fragments, rather than injecting them in fragment contents

parent 0abe75a7
No related branches found
No related tags found
No related merge requests found
<%namespace name='static' file='static_content.html'/>
% if is_xmodule:
<%static:webpack entry="${class_name}"/>
% endif
<!-- This is the xblock wrapper ${is_xmodule} -->
<div class="${' '.join(classes) | n}" ${data_attributes}>
% if js_init_parameters:
<script type="json/xblock-args" class="xblock-json-init-args">
......
......@@ -29,6 +29,8 @@ from xmodule.seq_module import SequenceModule
from xmodule.vertical_block import VerticalBlock
from xmodule.x_module import shim_xmodule_js, XModuleDescriptor, XModule, PREVIEW_VIEWS, STUDIO_VIEW
import webpack_loader.utils
log = logging.getLogger(__name__)
......@@ -134,8 +136,6 @@ def wrap_xblock(
'display_name': block.display_name_with_default_escaped,
'data_attributes': u' '.join(u'data-{}="{}"'.format(markupsafe.escape(key), markupsafe.escape(value))
for key, value in data.iteritems()),
'class_name': class_name,
'is_xmodule': isinstance(block, (XModule, XModuleDescriptor)),
}
if hasattr(frag, 'json_init_args') and frag.json_init_args is not None:
......@@ -144,6 +144,11 @@ def wrap_xblock(
else:
template_context['js_init_parameters'] = ""
if isinstance(block, (XModule, XModuleDescriptor)):
# Add the webpackified asset tags
for tag in webpack_loader.utils.get_as_tags(class_name):
frag.add_resource(tag, mimetype='text/html', placement='head')
return wrap_fragment(frag, render_to_string('xblock_wrapper.html', template_context))
......@@ -202,7 +207,6 @@ def wrap_xblock_aside(
'classes': css_classes,
'data_attributes': u' '.join(u'data-{}="{}"'.format(markupsafe.escape(key), markupsafe.escape(value))
for key, value in data.iteritems()),
'is_xmodule': False,
}
if hasattr(frag, 'json_init_args') and frag.json_init_args is not None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment