Skip to content

Provides a twig filter (escapeNonNbsp) to Craft CMS 2.5.x that allows you to put   characters inside field content that actually render as a no-breaking-space without removing the ability to escape other html entities such as &.

License

Notifications You must be signed in to change notification settings

RickKukiela/escapeNonNbsp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

escapeNonNbsp (Craft CMS 2.5.x Twig Extension)

Why does this exist?

This plugin was created to handle a conundrum I experienced working with designers that wanted to control the way text breaks on their layouts by using   in the fields they are editing. To accommodate this I initially started filtering all field output with |raw which would render the   as-is, however then single ampersands were being rendered as is, along with any other character that would otherwise be converted to an html entity. This plugin was created to combat that issue.

What does it do, exactly?

In a nutshell, it renders the text exactly as if you did {{ 'some text'|escape('html') }} except it takes the output from that and replaces   with regular old   before returning the string to the view.

Install Instructions

  1. Clone or download the zip.
  2. Place the "escapenonnbsp" folder inside your craft/plugins directory.
  3. Go to admin / settings / plugins.
  4. Install The plugin.

How to use

Inside your twig templates, just use it like any other filter

{% set test = "Some Raw text & characters but with non breaking space!"; %}
{{ test|escapeNonNbsp }}

The above will output:

Some Raw text & characters but with non breaking space!

About

Provides a twig filter (escapeNonNbsp) to Craft CMS 2.5.x that allows you to put   characters inside field content that actually render as a no-breaking-space without removing the ability to escape other html entities such as &.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages