Question

Drupal 9 theming documentation indicates that the Twig raw filter is deprecated in favor of verbatim.

The ds-field-expert.html.twig template uses raw to render the input in the prefix and suffix field, which is often HTML.

{{- settings['prefix']|raw -}}

verbatim in the Twig 2 documentation is not a filter, but instead wraps around content in the template, so wrapping the line of code does not actually go and get the prefix/suffix content. It just renders the twig.

What should I use instead of raw in this case so the markup I enter into the prefix and suffix field of a Display Suite expert field template renders as HTML and not plain text?
Will this template break in Drupal 9?

Était-ce utile?

La solution

The raw filter is still fine to use. The filter is not deprecated, only the raw tag.

From the Drupal 9 theming documentation:

As of Twig 1.x, the raw tag is deprecated in favor of verbatim.

Looking at the Twig 2.x documentation, you'll notice that the raw filter is not deprecated.

However, in the Twig 1.x documentation for the verbatim tag you can see that it replaced the raw tag in Twig 1.12. This is the cause of the deprecation in the Drupal 9 theming guide.

Note that there's a notice at the bottom of that page that says the tag was changed to help prevent confusion between the raw tag and raw filter.

The verbatim tag works in the exact same way as the old raw tag, but was renamed to avoid confusion with the raw filter.

Licencié sous: CC-BY-SA avec attribution
Non affilié à drupal.stackexchange
scroll top