Esempio n. 1
0
    def render(self):
        """
        Get this placeholder's rendered contents.

        :return: Rendered markup.
        :rtype: markupsafe.Markup
        """
        if not may_inject(self.context):
            return ""

        full_content = ""
        for layout in self.layouts:
            wrapper_start = "<div%s>" % get_html_attrs(self._get_wrapper_attrs(layout))
            buffer = []
            write = buffer.append
            self._render_layout(write, layout)
            content = "".join(buffer)
            full_content += (
                "%(wrapper_start)s%(content)s%(wrapper_end)s" % {
                    "wrapper_start": wrapper_start,
                    "content": content,
                    "wrapper_end": "</div>",
                })

        return Markup('<div class="placeholder-edit-wrap">%s</div>' % full_content)
Esempio n. 2
0
    def render(self):
        """
        Get this placeholder's rendered contents.

        :return: Rendered markup.
        :rtype: markupsafe.Markup
        """
        if not may_inject(self.context):
            return ""

        full_content = ""
        for layout in self.layouts:
            wrapper_start = "<div%s>" % get_html_attrs(
                self._get_wrapper_attrs(layout))
            buffer = []
            write = buffer.append
            self._render_layout(write, layout)
            content = "".join(buffer)
            full_content += ("%(wrapper_start)s%(content)s%(wrapper_end)s" % {
                "wrapper_start": wrapper_start,
                "content": content,
                "wrapper_end": "</div>",
            })

        return Markup(full_content)
Esempio n. 3
0
    def render(self):
        """
        Get this placeholder's rendered contents.

        :return: Rendered markup.
        :rtype: markupsafe.Markup
        """
        language = get_language()

        if not may_inject(self.context):
            return ""

        full_content = ""
        saved_view_config = self.view_config.saved_view_config
        for layout in self.layouts:
            cache_key = slugify(
                "shuup_xtheme_placeholders:placeholder_%s_%s_%s_%s_%s_%s" % (
                    (saved_view_config.pk if saved_view_config else ""),
                    (saved_view_config.status if saved_view_config else ""),
                    (
                        saved_view_config.modified_on.isoformat()
                        if saved_view_config and saved_view_config.modified_on
                        else ""
                    ),
                    language,
                    self.placeholder_name,
                    get_layout_data_key(self.placeholder_name, layout, self.context)
                )
            )
            layout_content = cache.get(cache_key)
            if (
                settings.SHUUP_XTHEME_USE_PLACEHOLDER_CACHE and
                saved_view_config and
                saved_view_config.status == SavedViewConfigStatus.PUBLIC and
                layout_content
            ):
                full_content += layout_content
            else:
                wrapper_start = "<div%s>" % get_html_attrs(self._get_wrapper_attrs(layout))
                buffer = []
                write = buffer.append
                self._render_layout(write, layout)
                content = "".join(buffer)
                layout_content = (
                    "%(wrapper_start)s%(content)s%(wrapper_end)s" % {
                        "wrapper_start": wrapper_start,
                        "content": content,
                        "wrapper_end": "</div>",
                    })
                cache.set(cache_key, layout_content)
                full_content += layout_content

        return Markup('<div class="placeholder-edit-wrap">%s</div>' % full_content)