diff --git a/core-bundle/contao/templates/twig/component/_rich_text.html.twig b/core-bundle/contao/templates/twig/component/_rich_text.html.twig new file mode 100644 index 00000000000..00ecdd5490f --- /dev/null +++ b/core-bundle/contao/templates/twig/component/_rich_text.html.twig @@ -0,0 +1,34 @@ +{# + This component outputs rich text content, that was typically composed by + an editor in the backend using the tinyMCE editor. + +
+

Lorem ipsum

+
+ + Mandatory variables: + @var string text + + Optional variables: + @var \Contao\CoreBundle\String\HtmlAttributes attributes + + Note: + You can either group all variables in an object named "rich_text" or + all directly in the context. Grouping under an object has precedence. +#} + +{% trans_default_domain "contao_default" %} + +{% block rich_text_component %} + {% set rich_text = rich_text|default(_context) %} + + {% set rich_text_attributes = attrs(rich_text.attributes|default) + .addClass('rte') + .mergeWith(rich_text_attributes|default) + %} + + {% block rich_text_inner %} + {{ rich_text.text|csp_inline_styles|insert_tag|encode_email|raw }} + {% endblock %} + +{% endblock %} diff --git a/core-bundle/contao/templates/twig/content_element/text.html.twig b/core-bundle/contao/templates/twig/content_element/text.html.twig index 9dcde58c44d..9d90a876c15 100644 --- a/core-bundle/contao/templates/twig/content_element/text.html.twig +++ b/core-bundle/contao/templates/twig/content_element/text.html.twig @@ -1,5 +1,6 @@ {% extends "@Contao/content_element/_base.html.twig" %} {% use "@Contao/component/_figure.html.twig" %} +{% use "@Contao/component/_rich_text.html.twig" %} {% set content_layout_attributes = attrs() .addClass('media media--' ~ layout, layout and image) @@ -22,12 +23,6 @@ {# Richtext #} {% block text %} - {% set text_attributes = attrs() - .addClass('rte') - .mergeWith(text_attributes|default) - %} - - {{ text|csp_inline_styles|insert_tag|encode_email|raw }} - + {% with {text, attributes: text_attributes|default} %}{{ block('rich_text_component') }}{% endwith %} {% endblock %} {% endblock %}