Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ Change log
Next version
~~~~~~~~~~~~

- Raised the minimum django-content-editor version to 10. The region renderer
moved into django-content-editor (``content_editor.renderer``);
``feincms3.renderer`` re-exports it, so existing imports keep working. Its
``RegionRenderer`` subclass keeps the deprecated compatibility APIs.
``RegionRenderer`` now renders containers, see the django-content-editor
documentation.
- Deprecated closer-based section rendering (``render_section_plugins`` and
``register_section_close``) in favor of containers. Migrate existing content
using ``content_editor.migrations_utils.compute_depths``, together with
this release.

- Added a guide for migrating from FeinCMS to feincms3.
- Documented using django-prose-editor instead of CKEditor 4 for the rich text
plugin.
Expand Down
48 changes: 46 additions & 2 deletions docs/guides/rendering.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Rendering
The default behavior of feincms3's renderer is to concatenate the
rendered result of individual plugins into one long HTML string.

.. note::

The region renderer lives in django-content-editor since version 10
(``content_editor.renderer``). ``feincms3.renderer`` re-exports it and adds
deprecated compatibility APIs, so the examples below work with both.

That may not always be what you want. This guide also describes a few
alternative methods of rendering plugins that may or may not be useful.

Expand Down Expand Up @@ -215,8 +221,46 @@ exactly:
renderer.register(ProjectTeaser, ..., subregion="teasers")


Grouping plugins into containers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Containers
~~~~~~~~~~

Plugins whose models set ``container = True`` contain the following plugins
with a greater ``depth``. Editors nest plugins in containers in the content
editor; use them when the editor decides what belongs together, e.g. for
accordions, tabs or columns. Their renderer receives the rendered children as
a third argument:

.. code-block:: python

class Accordion(PagePlugin):
container = True

title = models.CharField(max_length=200)

renderer.register(
Accordion,
template_renderer("plugins/accordion.html"),
)

.. code-block:: html+django

<details>
<summary>{{ plugin.title }}</summary>
{{ children }}
</details>

Subregions only ever group siblings, so they never cross a container
boundary. See the `django-content-editor documentation
<https://django-content-editor.readthedocs.io/en/latest/rendering.html>`__ for
details.

Closer-based sections (``render_section_plugins`` and
``register_section_close``) are deprecated in favor of containers.
``content_editor.migrations_utils.compute_depths`` migrates existing content.


Wrapping subregions
~~~~~~~~~~~~~~~~~~~

The previous example added an ``<div class="teasers">...</div>`` wrapper
element to a group of teasers. However, sometimes you want to allow some
Expand Down
5 changes: 5 additions & 0 deletions docs/ref/renderer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ Renderer (``feincms3.renderer``)

.. automodule:: feincms3.renderer
:members:

``RegionRenderer``, ``template_renderer``, ``render_in_context``,
``default_context`` and ``PluginNotRegisteredError`` are defined in
django-content-editor's ``content_editor.renderer`` module and re-exported
here.
Loading
Loading