Sometimes you have very special styling for ul, ol lists or other tags which are used in a text editor where you are not able to add class. This twig extension should help you to wrap that output in a div or add classes to it.
The editor extension need to be registered as symfony service.
services:
Sulu\Twig\Extensions\EditorExtension: ~
# Full configuration:
Sulu\Twig\Extensions\EditorExtension:
arguments:
- { ul: 'list' }
- 'div'
- 'editor'
If autoconfigure is not active you need to tag it with twig.extension.
{% set yourHtml = '<ul><li>Test</li></ul>' %}
{{ yourHtml|editor_classes }}
This will output:
<ul class="list"><li>Test</li></ul>
{% set yourHtml = '<ul><li>Test</li></ul>' %}
{{ yourHtml|editor_classes({ul: 'special-list'}) }}
This will output:
<ul class="special-list"><li>Test</li></ul>
{% set yourHtml = '<p>Test</p>' %}
{{ yourHtml|editor }}
This will output:
<div class="editor"><p>Test</p></div>
{% set yourHtml = '<p>Test</p>' %}
{{ yourHtml|editor('section') }}
This will output:
<section class="editor"><p>Test</p></section>
{% set yourHtml = '<p>Test</p>' %}
{{ yourHtml|editor(null, 'custom') }}
This will output:
<div class="custom"><p>Test</p></div>