@@ -250,6 +250,40 @@ Simply replace ``{{ title }}`` and/or ``{{ slogan }}`` with ``{% inline_field "t
250250 template files, you need to restart the server manually to see the changes.
251251
252252
253+ A little helper: the ``split `` filter
254+ -------------------------------------
255+
256+ .. index ::
257+ single: split filter
258+ single: choices in template components
259+
260+ If you load the ``cms_component `` template tag library, you can use the ``split `` filter to convert a string into a list.
261+ Some component properties require a list of values, such as the ``parent_classes `` or ``child_classes ``.
262+ You can use the ``split `` filter to convert a string into a list. For example, if you want to allow the
263+ **Hero component ** to be a child of the **Container or Column component **, you can set the ``parent_classes ``
264+ like this::
265+
266+ {% cms_component "Hero" name=_("My Hero Component") parent_classes="ContainerPlugin|ColumnPlugin"|split %}
267+
268+ ``split `` splits a string by the pipe character (``| ``) and returns a list of strings. If you prefer to use a different
269+ separator, you can pass it as an argument to the filter, like this::
270+
271+ {% cms_component "Hero" name=_("My Hero Component") parent_classes="ContainerPlugin,ColumnPlugin"|split:"," %}
272+
273+ Additionally, ``split `` can be used to create tuples as needed for the ``choices `` parameter of
274+ ``forms.ChoiceField ``. For example, if you want to create a choice field with two options, you can use the
275+ following code::
276+
277+ {% field "color" forms.ChoiceField choices=_("Red <red>|Green <green>|Default <blue>")|split name=_("Color") %}
278+
279+ The verbose choice label is appended by the actual value of the field between angle brackets (``<...> ``).
280+
281+ .. note ::
282+
283+ For translators it is important to know, that they **should not translate ** the value in angle brackets.
284+ The German translation of the above example string might be ``Rot <red>|Grün <green>|Standard <blue> ``.
285+
286+
253287Limitations of template components
254288----------------------------------
255289
0 commit comments