def render_to_page_load_async_html(self):
"""
Generates script tag containing Javascript to register an
asynchronously loading Javascript FrontEnd plugin against the core
front-end Kolibri app. It passes in the events that would trigger
loading the plugin, both multi-time firing events (events) and one time
firing events (once).
It also passes in information about the methods that the events should
be delegated to once the plugin has loaded.
TODO: What do we do with the extension parameter here?
:returns: HTML of a script tag to insert into a page.
"""
urls = [chunk['url'] for chunk in self.sorted_chunks()]
tags = self.frontend_message_tag() +\
['<script>{kolibri_name}.registerKolibriModuleAsync("{bundle}", ["{urls}"], {events}, {once});</script>'.format(
kolibri_name=django_settings.KOLIBRI_CORE_JS_NAME,
bundle=self.unique_slug,
urls='","'.join(urls),
events=json.dumps(self.events),
once=json.dumps(self.once),
)]
return mark_safe('\n'.join(tags))
评论列表
文章目录