Regions (feincms3.regions)

class feincms3.regions.Regions(*, contents, renderer, cache_key=None, timeout=None)[source]

Regions uses content_editor.contents.Contents and the feincms3.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, named handle_<subregion>. If subregion is not set or is falsy handle_default is invoked instead. This method raises a KeyError exception if no matching handler exists.

You probably want to call this method when overriding render.

handle_default(items, context)[source]

Renders items from the queue using the renderer instance as long as the items either have no subregion attribute or whose subregion attribute is an empty string.

render(region, context=None)[source]

Main function for rendering.

Starts the generator and assembles all fragments into a safe HTML string.

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 or None if the type shouldn’t be checked.

subregions should be set of allowed subregion attribute values or None if the subregion attribute shouldn’t be checked at all. Include None in the set if you want matches to succeed also when encountering an item without a subregion attribute.

feincms3.regions.cached_render(fn)[source]

Decorator for Regions.render methods implementing caching behavior

feincms3.templatetags.feincms3.render_region(context, regions, region, **kwargs)[source]

Render a single region. See Regions for additional details. Any and all keyword arguments are forwarded to the render method of the Regions instance.

Usage:

{% render_region regions "main" %}