<p>Try using the <code>raw</code> twig filter.</p>

<p><code>{{ variable|hacksaw(words='100')|raw }}</code></p>

<p>I did not test this answer since I have't used hacksaw yet. However I believe you can combine filters like this just fine.</p>

<p><a href="http://twig.sensiolabs.org/doc/filters/raw.html" rel="nofollow noreferrer">http://twig.sensiolabs.org/doc/filters/raw.html</a></p>

CC BY-SA 3.0
2016-11-01T21:12:47.350Z
Thanks @spAnser for the idea but unfortunately it didn't work. The output is still showing the the entity name rather than rendering it.
Benek Lisefski
CC BY-SA 3.0
2016-11-01T19:34:30.840Z
2016-11-01T19:34:30.840Z
spAnser
<p>I have used hacksaw on a few projects, but I haven't come across this before so I can't replicate it. The above answer may work but you could try reordering it to:</p>

<pre><code>{{ entry.thing|raw|hacksaw(words='100') }}
</code></pre>

<p>If this doesn't work, I'll try and replicate it. Can you paste the code for us?</p>

CC BY-SA 3.0
2016-11-05T22:39:48.813Z
Thanks Jay. Tried it in that order and still no luck. I've edited my original question with some more details.
Benek Lisefski
CC BY-SA 3.0
2016-11-02T15:07:28.243Z
2016-11-02T15:07:28.243Z
Jay
<p>You could try to fight that ampersand with the <code>htmlEntityDecode</code> filter that is included in my Craft Helpers plugin <a href="https://github.com/carlcs/craft-helpers" rel="noreferrer">https://github.com/carlcs/craft-helpers</a></p>

CC BY-SA 3.0
2016-11-08T00:13:46.377Z
2016-11-08T00:13:46.377Z
carlcs
<p>I'm using the <a href="https://github.com/ryanshrum/hacksaw" rel="nofollow noreferrer">Hacksaw</a> plugin to truncate text and it does a great job except instead of rendering HTML entities such as "&amp;", it's outputting them as "<code>&amp;amp;</code>". How can I correct this? Putting them in <code>allow=""</code> 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?</p>

<p><strong>Edit for more info...</strong></p>

<p>Example of text as it should appear:</p>

<pre><code>Colour &amp; Light; A House Re-crafted, cover &amp; pg.99-108
</code></pre>

<p>Example of text output from Hacksaw:</p>

<pre><code>Colour &amp;amp;amp; Light; A House Re-crafted, cover &amp;amp;amp; pg.99-108
</code></pre>

<p>Stupidly I hadn't looked at the HTML until now. It looks like the first <code>&amp;amp;</code> is rendering correctly but then there's a second partial entity after it?!</p>

<p>Template code I've tried:</p>

<pre><code>{% 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='...') %}
</code></pre>

<p>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.</p>

<p><strong>Edit for answer</strong></p>

<p>As per accepted answer below, final working code is:</p>

<pre><code>{% set summary = article.newsArticle.type('text').first().text|htmlEntityDecode|hacksaw(words='35', append='...') %}
</code></pre>

<p>The Craft Helpers plugins did the trick.</p>

CC BY-SA 3.0
2016-11-02T16:54:58.303Z
Is this happening for just `&` used in URLs or any `&`?
Brad Bell
CC BY-SA 3.0
2016-11-05T22:32:52.583Z
@BradBell no not in URLs. Any & in text from Rich Text fields.
Benek Lisefski
<plugins><plugin-hacksaw>
Hacksaw replacing "&" with "&amp;"
# Hacksaw replacing "&" with "&amp;"

(Asked by: username_0 on 2016-11-01)

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 &amp; Light; A House Re-crafted, cover &amp; 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.

**Tags:** plugins, plugin-hacksaw
> **Comments:**
> **username_1**: Is this happening for just `&` used in URLs or any `&`?  
> **username_0**: @BradBell no not in URLs. Any & in text from Rich Text fields.  

---

## 3 answers

### Answer by username_4 on 2016-11-08. Score: 5 | Accepted answer

You could try to fight that ampersand with the `htmlEntityDecode` filter that is included in my Craft Helpers plugin <https://github.com/carlcs/craft-helpers>


---

### Answer by username_2 on 2016-11-01. Score: 2

Try using the `raw` twig filter.

`{{ variable|hacksaw(words='100')|raw }}`

I did not test this answer since I have't used hacksaw yet. However I believe you can combine filters like this just fine.

<http://twig.sensiolabs.org/doc/filters/raw.html>

> **Comments:**
> **username_0**: Thanks @spAnser for the idea but unfortunately it didn't work. The output is still showing the the entity name rather than rendering it.  

---

### Answer by username_3 on 2016-11-02. Score: 1

I have used hacksaw on a few projects, but I haven't come across this before so I can't replicate it. The above answer may work but you could try reordering it to:
{{ entry.thing|raw|hacksaw(words='100') }}

If this doesn't work, I'll try and replicate it. Can you paste the code for us?

> **Comments:**
> **username_0**: Thanks Jay. Tried it in that order and still no luck. I've edited my original question with some more details.  

---

