Esempio n. 1
0
def get_test_template_bits(request, pass_view=True, **extra_ctx):
    layout = Layout(FauxTheme, "test")
    gibberish = printable_gibberish()
    layout.begin_column({"md": 12, "xs": 0})
    layout.add_plugin("text", {"text": gibberish})
    jeng = get_jinja2_engine()
    template = jeng.from_string("")
    template.template.name = "test"
    vars = {"view": pass_view and FauxView(), "request": request}
    vars.update(extra_ctx)
    ctx = template.template.new_context(vars)
    return (template, layout, gibberish, ctx)
Esempio n. 2
0
def get_test_template_bits(request, pass_view=True, **extra_ctx):
    layout = Layout(FauxTheme, "test")
    gibberish = printable_gibberish()
    layout.begin_column({"md": 12, "xs": 0})
    layout.add_plugin("text", {"text": gibberish})
    jeng = get_jinja2_engine()
    template = jeng.from_string("")
    template.template.name = "test"
    vars = {"view": pass_view and FauxView(), "request": request}
    vars.update(extra_ctx)
    ctx = template.template.new_context(vars)
    return (template, layout, gibberish, ctx)
Esempio n. 3
0
    def _new_layout(self, parser, placeholder_name):
        """
        Begin a new layout for the given placeholder in the parser.

        :param parser: Template parser
        :type parser: jinja2.parser.Parser
        :param placeholder_name: The name of the placeholder.
        :type placeholder_name: str
        :return: The new layout
        :rtype: shuup.xtheme.view_config.Layout
        :raises NestingError: Raised if there's a layout going on already.
        """
        curr_layout = self._get_layout(parser, accept_none=True)
        if curr_layout is not None:
            raise NestingError(
                "Can't nest `placeholder`s! (Currently in %r, trying to start %r)"
                % (curr_layout.placeholder_name, placeholder_name))
        layout = Layout(None, placeholder_name=placeholder_name)
        parser._xtheme_placeholder_layout = layout
        return self._get_layout(parser)