Regions (feincms3.regions)¶
Warning
This module is deprecated. Use feincms3.renderer.RegionRenderer
instead.
- class feincms3.regions.Regions(*, contents, renderer, cache_key=None, timeout=None)[source]¶
Regionsusescontent_editor.contents.Contentsand thefeincms3.renderer.TemplatePluginRendererto convert a list of plugins into a rendered representation, most often a HTML fragment.This class may also be instantiated directly but using the factory methods (starting with
from_) below is probably more comfortable.- classmethod from_contents(contents, *, renderer, **kwargs)[source]¶
Create and return a regions instance using the bare minimum of a contents instance and a renderer. Additional keyword arguments are forwarded to the regions constructor.
- classmethod from_item(item, *, renderer, inherit_from=None, timeout=None, **kwargs)[source]¶
Create and return a regions instance for an item (for example a page, an article or anything else managed by django-content-editor).
The item’s plugins are determined by what is registered with the renderer. The plugin instances themselves are loaded lazily, and loading every time can be avoided completely by specifying a
timeout.
- generate(items, context)[source]¶
Inspects all items in the region for a
subregionattribute and passes control to the subregions’ respective rendering handler, namedhandle_<subregion>. Ifsubregionis not set or is falsyhandle_defaultis invoked instead. This method raises aKeyErrorexception if no matching handler exists.You probably want to call this method when overriding
render.
- feincms3.regions.cached_render(fn)[source]¶
Decorator for
Regions.rendermethods implementing caching behavior
- feincms3.regions.matches(item, *, plugins=None, subregions=None)[source]¶
Checks whether the item matches zero or more constraints.
pluginsshould be a tuple of plugin classes orNoneif the type shouldn’t be checked.subregionsshould be set of allowedsubregionattribute values orNoneif thesubregionattribute shouldn’t be checked at all. IncludeNonein the set if you wantmatchesto succeed also when encountering an item without asubregionattribute.
- feincms3.templatetags.feincms3.render_region(context, regions, region, **kwargs)[source]¶
Render a single region. See
RegionRendererfor additional details.Usage:
{% render_region regions "main" %}