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]¶
Regions
usescontent_editor.contents.Contents
and thefeincms3.renderer.TemplatePluginRenderer
to 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
subregion
attribute and passes control to the subregions’ respective rendering handler, namedhandle_<subregion>
. Ifsubregion
is not set or is falsyhandle_default
is invoked instead. This method raises aKeyError
exception if no matching handler exists.You probably want to call this method when overriding
render
.
- feincms3.regions.cached_render(fn)[source]¶
Decorator for
Regions.render
methods implementing caching behavior
- feincms3.regions.matches(item, *, plugins=None, subregions=None)[source]¶
Checks whether the item matches zero or more constraints.
plugins
should be a tuple of plugin classes orNone
if the type shouldn’t be checked.subregions
should be set of allowedsubregion
attribute values orNone
if thesubregion
attribute shouldn’t be checked at all. IncludeNone
in the set if you wantmatches
to succeed also when encountering an item without asubregion
attribute.
- feincms3.templatetags.feincms3.render_region(context, regions, region, **kwargs)[source]¶
Render a single region. See
RegionRenderer
for additional details.Usage:
{% render_region regions "main" %}