From 794022733df0f6d865b1cbc823f31e3b08fc34b0 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 1 Jun 2012 16:34:00 -0400 Subject: [PATCH] Do json dumping and replacement as close to the template as possible --- djangoapps/courseware/modules/seq_module.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/djangoapps/courseware/modules/seq_module.py b/djangoapps/courseware/modules/seq_module.py index 5abe56231c..3604fa0a6a 100644 --- a/djangoapps/courseware/modules/seq_module.py +++ b/djangoapps/courseware/modules/seq_module.py @@ -40,15 +40,6 @@ class Module(XModule): def render(self): if self.rendered: return - def j(m): - ''' Split tags -- browsers handle this as end - of script, even if it occurs mid-string''' - content=m['content'].replace('', '<"+"/script>') - - return {'content':content, - 'type': m['type']} - - ## Returns a set of all types of all sub-children child_classes = [set([i.tag for i in e.iter()]) for e in self.xmltree] @@ -56,7 +47,6 @@ class Module(XModule): for e in self.xmltree] self.contents = self.rendered_children() - self.contents = [j(m) for m in self.contents] for contents, title in zip(self.contents, titles): contents['title'] = title @@ -68,7 +58,10 @@ class Module(XModule): new_class = c content['type'] = new_class - params={'items':self.contents, + # Split tags -- browsers handle this as end + # of script, even if it occurs mid-string. Do this after json.dumps()ing + # so that we can be sure of the quotations being used + params={'items':json.dumps(self.contents).replace('', '<"+"/script>'), 'id':self.item_id, 'position': self.position, 'titles':titles,