fix: refactor MakoService to allow specifying namespace per template (#33061)

This commit is contained in:
Braden MacDonald
2023-08-21 10:05:38 -07:00
committed by GitHub
parent bb28c27f96
commit d60cdc2305
25 changed files with 113 additions and 55 deletions

View File

@@ -282,7 +282,7 @@ class SplitTestBlock( # lint-amnesty, pylint: disable=abstract-method
sorted_inactive_contents = sorted(inactive_contents, key=itemgetter('group_name'))
# Use the new template
fragment.add_content(self.runtime.service(self, 'mako').render_template('split_test_staff_view.html', {
fragment.add_content(self.runtime.service(self, 'mako').render_lms_template('split_test_staff_view.html', {
'items': sorted_active_contents + sorted_inactive_contents,
}))
fragment.add_css('.split-test-child { display: none; }')
@@ -309,7 +309,7 @@ class SplitTestBlock( # lint-amnesty, pylint: disable=abstract-method
fragment, inactive_children, context
)
fragment.add_content(self.runtime.service(self, 'mako').render_template('split_test_author_view.html', {
fragment.add_content(self.runtime.service(self, 'mako').render_lms_template('split_test_author_view.html', {
'split_test': self,
'is_root': is_root,
'is_configured': self.is_configured,
@@ -348,7 +348,7 @@ class SplitTestBlock( # lint-amnesty, pylint: disable=abstract-method
Return the studio view.
"""
fragment = Fragment(
self.runtime.service(self, 'mako').render_template(self.mako_template, self.get_context())
self.runtime.service(self, 'mako').render_cms_template(self.mako_template, self.get_context())
)
add_webpack_js_to_fragment(fragment, 'SplitTestBlockEditor')
shim_xmodule_js(fragment, self.studio_js_module_name)
@@ -367,7 +367,7 @@ class SplitTestBlock( # lint-amnesty, pylint: disable=abstract-method
return self._staff_view(context)
else:
child_fragment = self.child.render(STUDENT_VIEW, context)
fragment = Fragment(self.runtime.service(self, 'mako').render_template('split_test_student_view.html', {
fragment = Fragment(self.runtime.service(self, 'mako').render_lms_template('split_test_student_view.html', {
'child_content': child_fragment.content,
'child_id': self.child.scope_ids.usage_id,
}))