I'm using the Hacksaw plugin to truncate text and it does a great job except instead of rendering HTML entities such as "&", it's outputting them as "&
". How can I correct this? Putting them in allow=""
doesn't work. Do I need to do something to manipulate the text string first before applying the Hacksaw filter? Or is there a Hacksaw option that would correct this?
Edit for more info...
Example of text as it should appear:
Colour & Light; A House Re-crafted, cover & pg.99-108
Example of text output from Hacksaw:
Colour & Light; A House Re-crafted, cover & pg.99-108
Stupidly I hadn't looked at the HTML until now. It looks like the first &
is rendering correctly but then there's a second partial entity after it?!
Template code I've tried:
{% set summary = article.newsArticle.type('text').first().text|hacksaw(words='35', append='...') %}
{% set summary = article.newsArticle.type('text').first().text|hacksaw(words='35', append='...')|raw %}
{% set summary = article.newsArticle.type('text').first().text|raw|hacksaw(words='35', append='...') %}
The order of plugin doesn't appear to have any effect. I get same result with all three of these arrangment above, including no Raw plugin at all.
Edit for answer
As per accepted answer below, final working code is:
{% set summary = article.newsArticle.type('text').first().text|htmlEntityDecode|hacksaw(words='35', append='...') %}
The Craft Helpers plugins did the trick.
&
used in URLs or any&
?