Sometimes it is useful to be able to format text using a one of the filter module's text formats defined at /admin/config/content/formats. Such as the Drupal "Basic HTML" or "Full HTML" filters, or a custom filter.

A common use case for this would be when using Rules to send email, if we want to ensure there is no unsafe markup in user-provided HTML.

This patch adds the 'format_text' typed data filter which may be used like this:
{{ node.body | format_text('full_html') }}

See https://www.drupal.org/docs/8/modules/d8-rules-essentials/token-replacem... more more information on using data filters.

CommentFileSizeAuthor
format-text-filter.patch1.99 KBtr

Comments

TR created an issue. See original summary.

tr’s picture

Issue summary: View changes

  • TR committed 22b26ce on 8.x-1.x
    Issue #3159812 by TR: Add format_text() data filter
    
tr’s picture

Status: Needs review » Fixed

Committed.

jonathan1055’s picture

Nice.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.