Skip to content

Latest commit

 

History

History
33 lines (26 loc) · 1.35 KB

README.md

File metadata and controls

33 lines (26 loc) · 1.35 KB

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!