• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.get_jinja2_engine函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中shuup_tests.xtheme.utils.get_jinja2_engine函数的典型用法代码示例。如果您正苦于以下问题:Python get_jinja2_engine函数的具体用法?Python get_jinja2_engine怎么用?Python get_jinja2_engine使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_jinja2_engine函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_argumented_row_fails

def test_argumented_row_fails():
    with pytest.raises(ValueError):
        get_jinja2_engine().from_string("""
        {% placeholder foo %}
        {% row {"var": e} %}{% endrow %}
        {% endplaceholder %}
        """)
开发者ID:ruqaiya,项目名称:shuup,代码行数:7,代码来源:test_parsing.py


示例2: test_nonconstant_column_arg_fails

def test_nonconstant_column_arg_fails():
    with pytest.raises(ValueError):
        get_jinja2_engine().from_string("""
        {% placeholder foo %}
        {% column {"var": e} %}{% endcolumn %}
        {% endplaceholder %}
        """)
开发者ID:ruqaiya,项目名称:shuup,代码行数:7,代码来源:test_parsing.py


示例3: test_nested_placeholders_fail

def test_nested_placeholders_fail():
    with pytest.raises(NestingError):
        get_jinja2_engine().from_string("""
        {% placeholder foo %}
            {% placeholder bar %}{% endplaceholder %}
        {% endplaceholder %}
        """)
开发者ID:ruqaiya,项目名称:shuup,代码行数:7,代码来源:test_parsing.py


示例4: test_placeholder_accepts_valid_global_parameter

def test_placeholder_accepts_valid_global_parameter():
    get_jinja2_engine().from_string("""
    {% placeholder "stuff" global %}
        {% plugin "text" %}
        text = "More stuff"
        {% endplugin %}
    {% endplaceholder %}
    """)
开发者ID:ruqaiya,项目名称:shuup,代码行数:8,代码来源:test_parsing.py


示例5: test_nonstring_but_constant_plugin_content_fails

def test_nonstring_but_constant_plugin_content_fails():
    with pytest.raises(NonConstant):
        get_jinja2_engine().from_string("""
        {% placeholder foo %}
            {% plugin "text" %}
            text = {{ 8 }}
            {% endplugin %}
        {% endplaceholder %}
        """)
开发者ID:ruqaiya,项目名称:shuup,代码行数:9,代码来源:test_parsing.py


示例6: test_placeholder_invalid_parameter

def test_placeholder_invalid_parameter():
    with pytest.raises(TemplateSyntaxError):
        get_jinja2_engine().from_string("""
        {% placeholder stuff some_invalid_parameter %}
            {% plugin "text" %}
            text = "Some stuff"
            {% endplugin %}
        {% endplaceholder %}
        """)
开发者ID:ruqaiya,项目名称:shuup,代码行数:9,代码来源:test_parsing.py


示例7: test_placeholder_parameter_quotes_or_no_quotes_okay

def test_placeholder_parameter_quotes_or_no_quotes_okay():
    parameter_markup = """
    {%% placeholder stuff %s %%}
        {%% plugin "text" %%}
        text = "More stuff"
        {%% endplugin %%}
    {%% endplaceholder %%}
    """
    get_jinja2_engine().from_string(parameter_markup % "global")
    get_jinja2_engine().from_string(parameter_markup % "\"global\"")
开发者ID:ruqaiya,项目名称:shuup,代码行数:10,代码来源:test_parsing.py


示例8: test_rendering

def test_rendering(edit, injectable, theme_class, global_type):
    request = get_request(edit)
    request.resolver_match = mock.Mock()
    request.resolver_match.app_name = "shuup"

    with override_current_theme_class(theme_class):
        with plugin_override():
            jeng = get_jinja2_engine()
            if global_type:
                template = jeng.get_template("global_complex.jinja")
            else:
                template = jeng.get_template("complex.jinja")
            view = FauxView()
            view.xtheme_injection = bool(injectable)
            output = template.render(context={
                "view": view,
                "request": request
            }, request=request)

            # From now on we render placholders in views that
            # actually can be edited.
            if injectable and theme_class:
                assert "wider column" in output
                assert "less wide column" in output

            if edit and injectable and theme_class:
                assert "xt-ph-edit" in output
                assert "data-xt-placeholder-name" in output
                assert "data-xt-row" in output
                assert "data-xt-cell" in output
                assert "XthemeEditorConfig" in output
开发者ID:ruqaiya,项目名称:shuup,代码行数:31,代码来源:test_rendering.py


示例9: test_simple_addon_injection

def test_simple_addon_injection():
    request = get_request(edit=False)
    jeng = get_jinja2_engine()
    template = jeng.get_template("resinject.jinja")

    with override_current_theme_class():
        with override_provides(
                "xtheme_resource_injection", ["shuup_tests.xtheme.test_addon_injections:add_test_injection",]):
            # TestInjector should add alert to end of the body for every request
            output = template.render(request=request)
            head, body = output.split("</head>", 1)
            assert "window.injectedFromAddon=true;" in body
开发者ID:gurch101,项目名称:shuup,代码行数:12,代码来源:test_addon_injections.py


示例10: test_layout_rendering_with_global_type

def test_layout_rendering_with_global_type(rf):
    request = get_request(edit=False)
    with override_current_theme_class(None):
        with plugin_override():
            jeng = get_jinja2_engine()
            template = jeng.from_string("")

            (template, layout, gibberish, ctx) = get_test_template_bits(request)

            global_class = "xt-global-ph"
            result = six.text_type(render_placeholder(ctx, "test", layout, template.template.name, global_type=True))
            assert global_class in result

            result = six.text_type(render_placeholder(ctx, "test", layout, template.template.name, global_type=False))
            assert global_class not in result
开发者ID:ruqaiya,项目名称:shuup,代码行数:15,代码来源:test_layout.py


示例11: test_resources

def test_resources():
    request = get_request(edit=False)
    with override_current_theme_class(None):
        with plugin_override():
            jeng = get_jinja2_engine()
            template = jeng.get_template("resinject.jinja")
            output = template.render(request=request)
            head, body = output.split("</head>", 1)
            assert "alert('xss')" in body  # the inline script
            assert '"bars": [1, 2, 3]' in head  # the script vars
            assert '(unknown resource type:' in body  # the png
            assert 'href="://example.com/css.css"' in head  # the css
            assert 'src="://example.com/js.js"' in body  # the js
            assert head.count(ResourceInjectorPlugin.meta_markup) == 1  # the duplicate meta
            assert ResourceInjectorPlugin.message in output  # the actual message
开发者ID:NamiStudio,项目名称:shuup,代码行数:15,代码来源:test_resources.py


示例12: test_theme_selection

def test_theme_selection():
    """
    Test that a theme with a `template_dir` actually affects template directory selection.
    """
    with override_current_theme_class(), override_provides("xtheme", [
        "shuup_tests.xtheme.utils:FauxTheme",
        "shuup_tests.xtheme.utils:FauxTheme2",
        "shuup_tests.xtheme.utils:H2G2Theme",
    ]):
        ThemeSettings.objects.all().delete()
        for theme in get_provide_objects("xtheme"):
            set_current_theme(theme.identifier)
            je = get_jinja2_engine()
            wrapper = (noop() if theme.identifier == "h2g2" else pytest.raises(TemplateDoesNotExist))
            with wrapper:
                t = je.get_template("42.jinja")
                content = t.render().strip()
                assert "a slice of lemon wrapped around a large gold brick" in content.replace("\n", " ")
开发者ID:NamiStudio,项目名称:shuup,代码行数:18,代码来源:test_theme_selection.py


示例13: test_templated_plugin

def test_templated_plugin():
    jeng = get_jinja2_engine()

    my_plugin_class = templated_plugin_factory("MyPlugin", "templated_plugin.jinja",
        inherited_variables=("name",),
        config_copied_variables=("greeting",),
        engine=jeng
    )
    top_context = {
        "name": printable_gibberish(),
    }
    config = {
        "greeting": "Good day"
    }
    plugin = my_plugin_class(config=config)
    assert isinstance(plugin, TemplatedPlugin)
    with override_current_theme_class(None):
        rendered_content = plugin.render(top_context)
        expected_content = "Good day %s" % top_context["name"]
        assert rendered_content == expected_content
开发者ID:shawnadelic,项目名称:shuup,代码行数:20,代码来源:test_plugin_api.py


示例14: test_rendering

def test_rendering(edit, injectable, theme_class, global_type):
    request = get_request(edit)
    with override_current_theme_class(theme_class):
        with plugin_override():
            jeng = get_jinja2_engine()
            if global_type:
                template = jeng.get_template("global_complex.jinja")
            else:
                template = jeng.get_template("complex.jinja")
            view = FauxView()
            view.xtheme_injection = bool(injectable)
            output = template.render(context={
                "view": view,
            }, request=request)
            assert "wider column" in output
            assert "less wide column" in output
            if edit and injectable and theme_class:
                assert "xt-ph-edit" in output
                assert "data-xt-placeholder-name" in output
                assert "data-xt-row" in output
                assert "data-xt-cell" in output
                assert "XthemeEditorConfig" in output
开发者ID:shawnadelic,项目名称:shuup,代码行数:22,代码来源:test_rendering.py


示例15: test_unplaceheld_cola_fails

def test_unplaceheld_cola_fails():
    with pytest.raises(NestingError):
        get_jinja2_engine().from_string("""{% column %}{% endcolumn %}""")
开发者ID:ruqaiya,项目名称:shuup,代码行数:3,代码来源:test_parsing.py


示例16: test_parsing

def test_parsing():
    with override_current_theme_class(None):
        jeng = get_jinja2_engine()
        template = jeng.get_template("complex.jinja")
        assert template  # it'sa me! template!
开发者ID:ruqaiya,项目名称:shuup,代码行数:5,代码来源:test_parsing.py


示例17: test_nonconstant_placeholder_name_fails

def test_nonconstant_placeholder_name_fails():
    with pytest.raises(NonConstant):
        get_jinja2_engine().from_string("""{% placeholder "foo" ~ foo %}{% endplaceholder %}""")
开发者ID:ruqaiya,项目名称:shuup,代码行数:3,代码来源:test_parsing.py


示例18: test_bare_placeholder_name_succeeds

def test_bare_placeholder_name_succeeds():
    get_jinja2_engine().from_string("""{% placeholder foo %}{% endplaceholder %}""")
开发者ID:ruqaiya,项目名称:shuup,代码行数:2,代码来源:test_parsing.py



注:本文中的shuup_tests.xtheme.utils.get_jinja2_engine函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python api.deltahours函数代码示例发布时间:2022-05-27
下一篇:
Python forms.get_form_data函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap