This twig filter, when applied to an escaped twig string will un-escape the & entity that the & in " " was converted to by the initial escaping process. This allows content editors to insert their own non-breaking space into fields to prevent text widows on rendered pages.
This plugin requires Craft CMS 4.0.0 or later. (See tag 1.0.0 for Caft CMS 3.x)
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require belniakmedia/craft-allow-nbsp-twig-filter
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for Allow Twig Filter.
We wanted a quick and easy way for our content editors to be able to insert entities manually without having them be escaped by the standard twig escape policy. This allows the standard escaping to happen and just unescapes   back to
Craft Template Example:
{{ entry.description | allowNbsp }}
Brought to you by Belniak Media, Inc.