How to use the feincms3.regions.Regions.from_item function in feincms3

To help you get started, we’ve selected a few feincms3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matthiask / feincms3 / tests / testapp / test_feincms3.py View on Github external
def test_plugin_template_instance(self):
        renderer = TemplatePluginRenderer()
        renderer.register_template_renderer(HTML, Template("{{ plugin.html|safe }}"))
        page = Page.objects.create(template_key="standard")
        HTML.objects.create(
            parent=page, ordering=10, region="main", html="<b>Hello</b>"
        )

        regions = Regions.from_item(page, renderer=renderer)
        self.assertEqual(regions.render("main", Context()), "<b>Hello</b>")
        self.assertEqual(regions.render("main", None), "<b>Hello</b>")
github matthiask / feincms3 / tests / testapp / test_feincms3.py View on Github external
)

        page = Page.objects.create(template_key="standard")
        HTML.objects.create(
            parent=page, ordering=10, region="main", html="<b>Hello</b>"
        )

        regions = Regions.from_item(page, renderer=renderer)
        self.assertEqual(regions.render("main", Context()), "<b>Hello</b>\n")

        regions = Regions.from_item(page, renderer=renderer)
        self.assertEqual(
            regions.render("main", Context({"outer": "Test"})), "<b>Hello</b>Test\n"
        )

        regions = Regions.from_item(page, renderer=renderer, timeout=3)
        self.assertEqual(
            regions.render("main", Context({"outer": "Test2"})), "<b>Hello</b>Test2\n"
        )
        regions = Regions.from_item(page, renderer=renderer, timeout=3)
        # Output stays the same.
        self.assertEqual(
            regions.render("main", Context({"outer": "Test3"})), "<b>Hello</b>Test2\n"
        )

        self.assertEqual(regions.cache_key("main"), "testapp.page-%s-main" % page.pk)