def render_tag(self, context, code, extra_bits, nodelist=None): request = context.get('request') if not code or not request: # an empty string was passed in or the variable is not available in the context if nodelist: return nodelist.render(context) return '' toolbar = get_toolbar_from_request(request) renderer = toolbar.get_content_renderer() if isinstance(code, StaticPlaceholder): static_placeholder = code else: kwargs = { 'code': code, 'defaults': { 'creation_method': StaticPlaceholder.CREATION_BY_TEMPLATE } } if 'site' in extra_bits: kwargs['site'] = get_current_site() else: kwargs['site_id__isnull'] = True static_placeholder = StaticPlaceholder.objects.get_or_create( **kwargs)[0] content = renderer.render_static_placeholder( static_placeholder, context=context, nodelist=nodelist, ) return content
def render(self, context, instance, placeholder): from cms.utils.plugins import downcast_plugins, build_plugin_tree context = super(AliasPlugin, self).render(context, instance, placeholder) request = context.get('request') if not request or instance.is_recursive(): return context if instance.plugin_id: plugins = instance.plugin.get_descendants().order_by('placeholder', 'path') plugins = [instance.plugin] + list(plugins) plugins = downcast_plugins(plugins, request=request) plugins = list(plugins) plugins[0].parent_id = None plugins = build_plugin_tree(plugins) context['plugins'] = plugins if instance.alias_placeholder_id: toolbar = get_toolbar_from_request(request) renderer = toolbar.content_renderer content = renderer.render_placeholder( placeholder=instance.alias_placeholder, context=context, editable=False, ) context['content'] = mark_safe(content) return context
def process_response(self, request, response): if not self.is_cms_request(request): return response from django.utils.cache import add_never_cache_headers toolbar = get_toolbar_from_request(request) if toolbar._cache_disabled: add_never_cache_headers(response) if hasattr(request, 'user') and request.user.is_staff and response.status_code != 500: try: if hasattr(request, 'cms_latest_entry'): pk = LogEntry.objects.filter( user=request.user, action_flag__in=(ADDITION, CHANGE) ).only('pk').order_by('-pk')[0].pk if request.cms_latest_entry != pk: request.session['cms_log_latest'] = pk # If there were no LogEntries, just don't touch the session. # Note that in the case of a user logging-in as another user, # request may have a cms_latest_entry attribute, but there are no # LogEntries for request.user. except IndexError: pass return response
def render_tag(self, context, name, extra_bits, nodelist=None): request = context.get('request') if not request: return '' validate_placeholder_name(name) toolbar = get_toolbar_from_request(request) renderer = toolbar.get_content_renderer() inherit = 'inherit' in extra_bits try: content = renderer.render_page_placeholder( slot=name, context=context, inherit=inherit, nodelist=nodelist, ) except PlaceholderNotFound: content = '' if not content and nodelist: return nodelist.render(context) return content
def render_segment_plugin(context, plugin, render_plugin): request = context['request'] context['djangocms_personalisation_is_visible'] = render_plugin toolbar = get_toolbar_from_request(request) if toolbar.uses_legacy_structure_mode: # We need to handle it the old way. Render ALL plugins on the page so # that the legacy structure board can display all of them. rendered = cms_tags.render_plugin(context, plugin) if render_plugin: return rendered else: # We had to render the plugin and all its sub-plugins above and # so that the legacy structure board sees the invisible plugins. # (js via sekizai). # We return nothing as content though, since the plugin should not # be visible. return '' else: # The new way. yay! # The structure including all the hidden plugins is handled # entirely separate. So we don't have to worry about it here. # We only need to render plugins that are actually visible. if render_plugin: return cms_tags.render_plugin(context, plugin) else: # FIXME: hmmm... why does the popup not work if the plugin is not # rendered? It should work without it. cms_tags.render_plugin(context, plugin) return ''
def render_tag(self, context, static_code, extra_bits, nodelist=None): request = context.get('request') if not static_code or not request: # an empty string was passed in or the variable is not available in the context if nodelist: return nodelist.render(context) return '' validate_placeholder_name(static_code) toolbar = get_toolbar_from_request(request) renderer = toolbar.get_content_renderer() alias = self._get_alias(request, static_code, extra_bits) if not alias: return '' # Get draft contents in edit or preview mode? get_draft_content = False if toolbar.edit_mode_active or toolbar.preview_mode_active: get_draft_content = True language = get_language_from_request(request) placeholder = alias.get_placeholder(language=language, show_draft_content=get_draft_content) if placeholder: content = renderer.render_placeholder( placeholder=placeholder, context=context, nodelist=nodelist, ) return content return ''
def render_tag(self, context, plugin): if not plugin: return '' if CMS_LT_3_4: content_renderer = context['cms_content_renderer'] content = content_renderer.render_plugin( instance=plugin, context=context, editable=content_renderer.user_is_on_edit_mode(), ) else: toolbar = get_toolbar_from_request(context['request']) if 'cms_renderer' in context.dicts[1]: content_renderer=context.dicts[1]['cms_renderer'] elif 'cms_content_renderer' in context: content_renderer=context['cms_content_renderer'] else: content_renderer = toolbar.content_renderer content = content_renderer.render_plugin( instance=plugin, context=context, editable=toolbar.edit_mode_active, ) return content
def process_response(self, request, response): if not self.is_cms_request(request): return response from django.utils.cache import add_never_cache_headers toolbar = get_toolbar_from_request(request) if toolbar._cache_disabled: add_never_cache_headers(response) if hasattr(request, 'user' ) and request.user.is_staff and response.status_code != 500: try: if hasattr(request, 'cms_latest_entry'): pk = LogEntry.objects.filter( user=request.user, action_flag__in=( ADDITION, CHANGE)).only('pk').order_by('-pk')[0].pk if request.cms_latest_entry != pk: request.session['cms_log_latest'] = pk # If there were no LogEntries, just don't touch the session. # Note that in the case of a user logging-in as another user, # request may have a cms_latest_entry attribute, but there are no # LogEntries for request.user. except IndexError: pass return response
def render_extra_menu_items(context, obj, template='cms/toolbar/dragitem_extra_menu.html'): request = context['request'] toolbar = get_toolbar_from_request(request) template = toolbar.templates.get_cached_template(template) if isinstance(obj, CMSPlugin): items = [] for plugin_class in plugin_pool.plugins_with_extra_menu: plugin_items = plugin_class.get_extra_plugin_menu_items( request, obj) if plugin_items: items.extend(plugin_items) elif isinstance(obj, PlaceholderModel): items = [] for plugin_class in plugin_pool.plugins_with_extra_placeholder_menu: plugin_items = plugin_class.get_extra_placeholder_menu_items( request, obj) if plugin_items: items.extend(plugin_items) else: items = [] if not items: return '' return template.render({'items': items})
def render_tag(self, context, plugin): if not plugin: return '' if LooseVersion(CMS_VERSION) < LooseVersion('3.5'): content_renderer = context['cms_content_renderer'] content = content_renderer.render_plugin( instance=plugin, context=context, editable=content_renderer.user_is_on_edit_mode(), ) else: toolbar = get_toolbar_from_request(context['request']) if 'cms_content_renderer' in context and context[ 'cms_content_renderer'].__module__ == "cmsplugin_cascade.strides": content_renderer = context['cms_content_renderer'] elif 'cms_renderer' in context.dicts[1]: content_renderer = context.dicts[1]['cms_renderer'] elif 'cms_content_renderer' in context: content_renderer = context['cms_content_renderer'] else: content_renderer = toolbar.content_renderer content = content_renderer.render_plugin( instance=plugin, context=context, editable=toolbar.edit_mode_active, ) return content
def process_response(self, request, response): """Modifies response on it's way out, mostly useless stuff, probably could chuck it""" if not self.is_cms_request(request): return response toolbar = get_toolbar_from_request(request) if toolbar: add_never_cache_headers(response) if hasattr(request, 'user' ) and request.user.is_staff and response.status_code != 500: try: if hasattr(request, 'cms_latest_entry'): log_entries = LogEntry.objects.filter( user=request.user, action_flag__in=( ADDITION, CHANGE)).only('pk').order_by('-pk')[0].pk if request.cms_latest_entry != log_entries: request.session['cms_log_latest'] = log_entries # If there were no LogEntries, just don't touch the session. # Note that in the case of a user logging-in as another user, # request may have a cms_latest_entry attribute, but there are no # LogEntries for request.user. except IndexError: pass return response
def render_tag(self, context, plugin): if not plugin: return '' if LooseVersion(CMS_VERSION) < LooseVersion('3.5'): content_renderer = context['cms_content_renderer'] content = content_renderer.render_plugin( instance=plugin, context=context, editable=content_renderer.user_is_on_edit_mode(), ) else: toolbar = get_toolbar_from_request(context['request']) if 'cms_content_renderer' in context and context['cms_content_renderer'].__module__=="cmsplugin_cascade.strides" : content_renderer=context['cms_content_renderer'] elif 'cms_renderer' in context.dicts[1]: content_renderer=context.dicts[1]['cms_renderer'] elif 'cms_content_renderer' in context: content_renderer=context['cms_content_renderer'] else: content_renderer = toolbar.content_renderer content = content_renderer.render_plugin( instance=plugin, context=context, editable=toolbar.edit_mode_active, ) return content
def set_page_cache(response): from django.core.cache import cache request = response._request toolbar = get_toolbar_from_request(request) is_authenticated = request.user.is_authenticated() if is_authenticated or toolbar._cache_disabled or not get_cms_setting( "PAGE_CACHE"): add_never_cache_headers(response) return response # This *must* be TZ-aware timestamp = now() placeholders = toolbar.content_renderer.get_rendered_placeholders() # Checks if there's a plugin using the legacy "cache = False" placeholder_ttl_list = [] vary_cache_on_set = set() for ph in placeholders: # get_cache_expiration() always returns: # EXPIRE_NOW <= int <= MAX_EXPIRATION_IN_SECONDS ttl = ph.get_cache_expiration(request, timestamp) vary_cache_on = ph.get_vary_cache_on(request) placeholder_ttl_list.append(ttl) if ttl and vary_cache_on: # We're only interested in vary headers if they come from # a cache-able placeholder. vary_cache_on_set |= set(vary_cache_on) if EXPIRE_NOW not in placeholder_ttl_list: if placeholder_ttl_list: min_placeholder_ttl = min(x for x in placeholder_ttl_list) else: # Should only happen when there are no placeholders at all min_placeholder_ttl = MAX_EXPIRATION_TTL ttl = min( get_cms_setting('CACHE_DURATIONS')['content'], min_placeholder_ttl) if ttl > 0: # Adds expiration, etc. to headers patch_response_headers(response, cache_timeout=ttl) patch_vary_headers(response, sorted(vary_cache_on_set)) version = _get_cache_version() # We also store the absolute expiration timestamp to avoid # recomputing it on cache-reads. expires_datetime = timestamp + timedelta(seconds=ttl) cache.set(_page_cache_key(request), ( response.content, response._headers, expires_datetime, ), ttl, version=version) # See note in invalidate_cms_page_cache() _set_cache_version(version) return response
def detail(request, poll_id): try: poll = FancyPoll.objects.get(pk=poll_id) except FancyPoll.DoesNotExist: raise Http404('Fancy Poll doesn\'t exist') toolbar = get_toolbar_from_request(request) toolbar.set_object(poll) return render(request, poll.template, {'poll': poll})
def render_plugin(context, plugin): request = context['request'] toolbar = get_toolbar_from_request(request) renderer = toolbar.get_content_renderer() content = renderer.render_plugin( instance=plugin, context=context, editable=renderer._placeholders_are_editable, ) return content
def render_tag(self, context, name, nodelist): request = context.get('request') if not request: return nodelist.render(context) toolbar = get_toolbar_from_request(request) if toolbar and toolbar.show_toolbar: toolbar.init_toolbar(request) return toolbar.render_with_structure(context, nodelist) return nodelist.render(context)
def render_tag(self, context, name, page_lookup, extra_bits, nodelist=None): validate_placeholder_name(name) request = context.get("request") if request: page = _get_page_by_untyped_arg(page_lookup, request, get_site_id(None)) toolbar = get_toolbar_from_request(request) renderer = toolbar.get_content_renderer() inherit = "inherit" in extra_bits # A placeholder is only editable on its own page editable = page == request.current_page try: content = renderer.render_page_placeholder( slot=name, context=context, inherit=inherit, page=page, nodelist=nodelist, editable=editable, ) except PlaceholderNotFound: content = "" else: content = "" if not content and nodelist: content = nodelist.render(context) if "as" in extra_bits: try: varname = extra_bits[extra_bits.index("as") + 1] except IndexError: raise template.TemplateSyntaxError( 'the "as" word should be followed by the variable name') context[varname] = content return "" return content
def render_url(context, instance): request = context["request"] toolbar = get_toolbar_from_request(request) # Are we in an editable mode? show_draft_content = False if toolbar.edit_mode_active or toolbar.preview_mode_active: show_draft_content = True url = instance.get_content(show_draft_content) if not url: return "" renderer = toolbar.get_content_renderer() return url.get_url(renderer.current_site)
def _test_plugin_html(self): placeholder = Placeholder.objects.create(slot='test') model_instance = add_plugin( placeholder, CameraSliderPlugin, 'en', ) toolbar = get_toolbar_from_request({}) renderer = toolbar.get_content_renderer() html = renderer.render_plugin( instance=model_instance, context={}, editable=renderer._placeholders_are_editable, ) self.assertTrue(html.find('class="cameraslider">') > -1)
def menu_renderer_cache_key(self): prefix = get_cms_setting("CACHE_PREFIX") key = "%smenu_nodes_%s_%s" % (prefix, self.request_language, self.site.pk) if self.request.user.is_authenticated: key += "_%s_user" % self.request.user.pk request_toolbar = get_toolbar_from_request(self.request) if request_toolbar.edit_mode_active or request_toolbar.preview_mode_active: key += ":draft" else: key += ":public" return key
def render_tag(self, context, name, page_lookup, varname, extra_bits, nodelist=None): """ Retrieves the placeholder's plugins and set them as a variable in the template context. If the placeholder is empty, render the block as fallback content and return the resulting HTML. If the placholder is editable, the edit script and markup are added to the HTML content. """ content = "" request = context.get("request") if request: page = _get_page_by_untyped_arg(page_lookup, request, get_site_id(None)) try: placeholder = page.placeholders.get(slot=name) except ObjectDoesNotExist: context[varname] = [] return "" else: context[varname] = [ cms_plugin.get_plugin_instance()[0] for cms_plugin in get_plugins( request, placeholder, template=page.get_template()) ] # Default content if there is no plugins in the placeholder if not context[varname] and nodelist: content = nodelist.render(context) # Add the edit script and markup to the content, only if the placeholder is editable # and the visited page is the one on which the placeholder is declared. toolbar = get_toolbar_from_request(request) if placeholder.page == request.current_page and toolbar.edit_mode_active: renderer = toolbar.get_content_renderer() data = renderer.get_editable_placeholder_context(placeholder, page=page) data["content"] = content content = renderer.placeholder_edit_template.format(**data) return content
def prepare_text(self, obj): request = get_request(obj.language) context = RequestContext(request) if 'request' not in context: context['request'] = request toolbar = get_toolbar_from_request(request) renderer = toolbar.get_content_renderer() source = obj.placeholder if not source: return content = renderer.render_placeholder( placeholder=source, context=context, editable=False, ) return content
def render_alias(context, instance, editable=False): request = context['request'] toolbar = get_toolbar_from_request(request) renderer = toolbar.get_content_renderer() editable = editable and renderer._placeholders_are_editable source = instance.get_placeholder() if source: content = renderer.render_placeholder( placeholder=source, context=context, editable=editable, ) return content or '' return ''
def _show_placeholder_by_id(context, placeholder_name, reverse_id, lang=None, site=None, use_cache=True): validate_placeholder_name(placeholder_name) request = context['request'] toolbar = get_toolbar_from_request(request) renderer = toolbar.get_content_renderer() if site: # Backwards compatibility. # Assume user passed in a pk directly. site_id = getattr(site, 'pk', site) else: site_id = renderer.current_site.pk page = _get_page_by_untyped_arg(reverse_id, request, site_id) if not page: return '' try: placeholder = page.placeholders.get(slot=placeholder_name) except PlaceholderModel.DoesNotExist: if settings.DEBUG: raise return '' else: # save a query. cache the page. placeholder.page = page content = renderer.render_placeholder( placeholder=placeholder, context=context, language=lang, page=page, editable=False, use_cache=use_cache, ) return content
def render_tag(self, context, plugin): if not plugin: return '' request = context['request'] toolbar = get_toolbar_from_request(request) if 'cms_content_renderer' in context and isinstance(context['cms_content_renderer'], StrideContentRenderer): content_renderer = context['cms_content_renderer'] elif 'cms_renderer' in context: content_renderer = context['cms_renderer'] elif 'cms_content_renderer' in context: content_renderer = context['cms_content_renderer'] else: content_renderer = toolbar.content_renderer content = content_renderer.render_plugin( instance=plugin, context=context, editable=toolbar.edit_mode_active, ) return content
def render_tag(self, context, plugin, nodelist): """ Renders the block for the plugin and returns the resulting HTML leaving the temmpate context untouched. If the placeholder is editable, the edit script and markup are added to the rendered HTML. """ request = context.get("request") if not plugin or not request: return "" # Add the plugin and its rendered content to an internal context internal_context = flatten_context(context) internal_context["instance"] = plugin internal_context["content"] = nodelist.render(context.new(internal_context)) # Add the edit script and markup to the content, only if the placeholder is editable # and the visited page is the one on which the plugin's placeholder is declared. toolbar = get_toolbar_from_request(request) if plugin.placeholder.page == request.current_page and toolbar.edit_mode_active: return render_to_string(self.template, internal_context) return internal_context["content"]
def _get_value(self, context, editable=True, **kwargs): request = context['request'] toolbar = get_toolbar_from_request(request) renderer = toolbar.get_content_renderer() placeholder = kwargs.get('placeholder') nocache = kwargs.get('nocache', False) if not placeholder: return '' if isinstance(placeholder, str): placeholder = PlaceholderModel.objects.get(slot=placeholder) content = renderer.render_placeholder( placeholder=placeholder, context=context, language=kwargs.get('language'), editable=editable, use_cache=not nocache, width=kwargs.get('width'), ) return content
def render_alias_plugin(context, instance): request = context['request'] toolbar = get_toolbar_from_request(request) renderer = toolbar.content_renderer source = (instance.plugin or instance.alias_placeholder) # In edit mode, content is shown regardless of the source page publish status. # In published mode, content is shown only if the source page is published. if not (toolbar.edit_mode_active) and source and source.page: # this is bad but showing unpublished content is worse can_see_content = source.page.is_published(instance.language) else: can_see_content = True if can_see_content and instance.plugin: plugins = instance.plugin.get_descendants().order_by( 'placeholder', 'path') plugins = [instance.plugin] + list(plugins) plugins = downcast_plugins(plugins, request=request) plugins = list(plugins) plugins[0].parent_id = None plugins = build_plugin_tree(plugins) content = renderer.render_plugin( instance=plugins[0], context=context, editable=False, ) return mark_safe(content) if can_see_content and instance.alias_placeholder: content = renderer.render_placeholder( placeholder=instance.alias_placeholder, context=context, editable=False, ) return mark_safe(content) return ''
def cms_settings(request): """ Adds cms-related variables to the context. """ from menus.menu_pool import MenuRenderer @lru_cache.lru_cache(maxsize=None) def _get_menu_renderer(): # We use lru_cache to avoid getting the manager # every time this function is called. from menus.menu_pool import menu_pool return menu_pool.get_renderer(request) toolbar = get_toolbar_from_request(request) # Now use lazy() to avoid getting the menu renderer # up until the point is needed. # lazy() does not memoize results, is why lru_cache is needed. _get_menu_renderer = lazy(_get_menu_renderer, MenuRenderer) return { 'cms_menu_renderer': _get_menu_renderer(), 'cms_content_renderer': toolbar.content_renderer, 'CMS_MEDIA_URL': get_cms_setting('MEDIA_URL'), 'CMS_TEMPLATE': lambda: get_template_from_request(request), }
def set_page_cache(response): from django.core.cache import cache request = response._request toolbar = get_toolbar_from_request(request) is_authenticated = request.user.is_authenticated() if is_authenticated or toolbar._cache_disabled or not get_cms_setting("PAGE_CACHE"): add_never_cache_headers(response) return response # This *must* be TZ-aware timestamp = now() placeholders = toolbar.content_renderer.get_rendered_placeholders() # Checks if there's a plugin using the legacy "cache = False" placeholder_ttl_list = [] vary_cache_on_set = set() for ph in placeholders: # get_cache_expiration() always returns: # EXPIRE_NOW <= int <= MAX_EXPIRATION_IN_SECONDS ttl = ph.get_cache_expiration(request, timestamp) vary_cache_on = ph.get_vary_cache_on(request) placeholder_ttl_list.append(ttl) if ttl and vary_cache_on: # We're only interested in vary headers if they come from # a cache-able placeholder. vary_cache_on_set |= set(vary_cache_on) if EXPIRE_NOW not in placeholder_ttl_list: if placeholder_ttl_list: min_placeholder_ttl = min(x for x in placeholder_ttl_list) else: # Should only happen when there are no placeholders at all min_placeholder_ttl = MAX_EXPIRATION_TTL ttl = min( get_cms_setting('CACHE_DURATIONS')['content'], min_placeholder_ttl ) if ttl > 0: # Adds expiration, etc. to headers patch_response_headers(response, cache_timeout=ttl) patch_vary_headers(response, sorted(vary_cache_on_set)) version = _get_cache_version() # We also store the absolute expiration timestamp to avoid # recomputing it on cache-reads. expires_datetime = timestamp + timedelta(seconds=ttl) cache.set( _page_cache_key(request), ( response.content, response._headers, expires_datetime, ), ttl, version=version ) # See note in invalidate_cms_page_cache() _set_cache_version(version) return response
def toolbar(self): return get_toolbar_from_request(self.request)
def toolbar(self): return get_toolbar_from_request(self.request)
def render_url(context, instance): request = context["request"] toolbar = get_toolbar_from_request(request) renderer = toolbar.get_content_renderer() return instance.get_url(renderer.current_site)
def get_nodes(self, request): site = self.renderer.site language = self.renderer.request_language pages_qs = get_page_queryset(site).select_related('node') visible_pages_for_user = get_visible_nodes(request, pages_qs, site) if not visible_pages_for_user: return [] cms_extension = apps.get_app_config( 'djangocms_versioning').cms_extension toolbar = get_toolbar_from_request(request) edit_or_preview = toolbar.edit_mode_active or toolbar.preview_mode_active menu_nodes = [] node_id_to_page = {} homepage_content = None # Depending on the toolbar mode, we need to get the correct version. # On edit or preview mode: return DRAFT, # if DRAFT does not exists then return PUBLISHED. # On public mode: return PUBLISHED. if edit_or_preview: states = [constants.DRAFT, constants.PUBLISHED] else: states = [constants.PUBLISHED] versionable_item = cms_extension.versionables_by_grouper[Page] versioned_page_contents = ( versionable_item.content_model._base_manager.filter( language=language, page__in=pages_qs, versions__state__in=states, ).order_by('page__node__path', 'versions__state').select_related( 'page', 'page__node').prefetch_related('versions')) added_pages = [] for page_content in versioned_page_contents: page = page_content.page if page not in visible_pages_for_user: # The page is restricted for the user. # Therefore we avoid adding it to the menu. continue version = page_content.versions.all()[0] if (page.pk in added_pages and edit_or_preview and version.state == constants.PUBLISHED): # Page content is already added. This is the case where you # have both draft and published and in edit/preview mode. # We give priority to draft which is already sorted by the query. # Therefore we ignore the published version. continue page_tree_node = page.node parent_id = node_id_to_page.get(page_tree_node.parent_id) if page_tree_node.parent_id and not parent_id: # If the parent page is not available, # we skip adding the menu node. continue # Construct the url based on the toolbar mode. if edit_or_preview: url = get_object_preview_url(page_content) else: url = page_content.get_absolute_url() # Create the new navigation node. new_node = CMSVersionedNavigationNode( id=page.pk, attr=_get_attrs_for_node(self.renderer, page_content), title=page_content.menu_title or page_content.title, url=url, visible=page_content.in_navigation, ) if not homepage_content: # Set the home page content. homepage_content = page_content if page.is_home else None cut_homepage = homepage_content and not homepage_content.in_navigation if cut_homepage and parent_id == homepage_content.page.pk: # When the homepage is hidden from navigation, # we need to cut all its direct children from it. new_node.parent_id = None else: new_node.parent_id = parent_id node_id_to_page[page_tree_node.pk] = page.pk menu_nodes.append(new_node) added_pages.append(page.pk) return menu_nodes
def _render_placeholder(placeholder, context, **kwargs): request = context['request'] toolbar = get_toolbar_from_request(request) content_renderer = toolbar.content_renderer context['cms_content_renderer'] = content_renderer return content_renderer.render_placeholder(placeholder, context, **kwargs)