def render_plugin_toolbar_config(context, plugin): content_renderer = context['cms_content_renderer'] instance, plugin_class = plugin.get_plugin_instance() if not instance: return '' with context.push(): content = content_renderer.render_editable_plugin( instance, context, plugin_class, ) # render_editable_plugin will populate the plugin # parents and children cache. placeholder_cache = content_renderer.get_rendered_plugins_cache(instance.placeholder) toolbar_js = get_plugin_toolbar_js( instance, request_language=content_renderer.request_language, children=placeholder_cache['plugin_children'][instance.plugin_type], parents=placeholder_cache['plugin_parents'][instance.plugin_type], ) varname = get_varname() toolbar_js = '<script>{}</script>'.format(toolbar_js) # Add the toolbar javascript for this plugin to the # sekizai "js" namespace. context[varname]['js'].append(toolbar_js) return mark_safe(content)
def render_plugin_toolbar_config(context, plugin): content_renderer = context['cms_content_renderer'] instance, plugin_class = plugin.get_plugin_instance() if not instance: return '' with context.push(): content = content_renderer.render_editable_plugin( instance, context, plugin_class, ) # render_editable_plugin will populate the plugin # parents and children cache. placeholder_cache = content_renderer.get_rendered_plugins_cache( instance.placeholder) toolbar_js = get_plugin_toolbar_js( instance, request_language=content_renderer.request_language, children=placeholder_cache['plugin_children'][ instance.plugin_type], parents=placeholder_cache['plugin_parents'][instance.plugin_type], ) varname = get_varname() toolbar_js = '<script>{}</script>'.format(toolbar_js) # Add the toolbar javascript for this plugin to the # sekizai "js" namespace. context[varname]['js'].append(toolbar_js) return mark_safe(content)
def get_plugin_toolbar_js(self, plugin, page=None): placeholder_cache = self._rendered_plugins_by_placeholder.setdefault(plugin.placeholder_id, {}) child_classes, parent_classes = get_plugin_restrictions( plugin=plugin, page=page, restrictions_cache=placeholder_cache, ) content = get_plugin_toolbar_js( plugin, children=child_classes, parents=parent_classes, ) return content