Update to use generic studioContext configuration

This commit is contained in:
Farhanah Sheets
2017-11-30 15:04:44 -05:00
parent 989c3a30d7
commit e395e78521
3 changed files with 15 additions and 20 deletions

View File

@@ -101,25 +101,18 @@ source, template_path = Loader(engine).load_template_source(path)
from webpack_loader.exceptions import WebpackLoaderBadStatsError
import json
def _convert_dict_to_json(input_dict):
output_json = "{"
for key in input_dict:
output_json = "{}{}:\"{}\",".format(output_json, key, input_dict[key])
output_json += "}"
return output_json
body = capture(caller.body)
body_dict = json.loads(body)
body_dict['lang'] = lang
return Template("""
<script type="text/javascript" id='courseContext'>
var courseContext = {% autoescape off %}{{ body }}{% endautoescape %};
<script type="text/javascript" id='studioContext'>
var studioContext = {% autoescape off %}{{ body }}{% endautoescape %};
</script>
<div id="root"></div>
{% load render_bundle from webpack_loader %}
{% render_bundle page %}
""").render(Context({
'body': _convert_dict_to_json(body_dict),
'body': json.dumps(body_dict),
'page': page
}))
%>