hooks.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:kolibri 作者: learningequality 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号