<p>It's escaping the text in the default (html) context, which should not be happening for a template you <code>include</code></p>

<p>I suspect this is due to a larger issue, as templates that are included should not be escaped in this manner.</p>

<p>You can change the escaping strategy using block tags around the code, though:</p>

<pre><code>{% autoescape false %}
{% endautoescape %}
</code></pre>

<p>cf: <a href="https://twig.symfony.com/doc/2.x/tags/autoescape.html" rel="nofollow noreferrer">autoescape</a></p>

CC BY-SA 3.0
2018-03-26T11:52:37.477Z
Unfortunately this hasn't resolved the issue. I have updated my original question with the variations I have tried. Any other ideas would be appreciated.
Terry Upton
CC BY-SA 3.0
2018-03-28T14:04:38.643Z
If that doesn't work, something else is deeply wrong here.
andrew.welch
CC BY-SA 3.0
2018-03-22T15:23:31.493Z
2018-03-22T15:23:31.493Z
andrew.welch
<p>So I have an include file.</p>

<pre><code>&lt;noscript&gt;
  &lt;img
    src="{{ srcImage }}"
    alt="{{ alt }}"
  /&gt;
&lt;/noscript&gt;
</code></pre>

<p>I am including like standard:</p>

<pre><code>{% include '_includes/partials/image-noscript' %
</code></pre>

<p>but for some reason it is generating the code like so…</p>

<pre><code>&lt;noscript&gt;
  &amp;lt;img
    src="http://plowmancraven-v4.loc/imager/uploads/images/general/3172/PC-Enviro-Generic-London-shutterstock_370946690_3488bcae28a5a46889970c4f238b0c7c.jpg"
    alt="PC Enviro Generic London"
  /&amp;gt;
&lt;/noscript&gt;
</code></pre>

<p>Edit: Here are some of the things I have tried but nothing has solved this issue yet.</p>

<pre><code>{%- include '_includes/partials/image-noscript' -%}
{% autoescape false %}{% include '_includes/partials/image-noscript' %}{% endautoescape %}
</code></pre>

<p>inside the included file:</p>

<pre><code>&lt;noscript&gt;&lt;img src="{{ srcImage }}" alt="{{ alt }}" /&gt;&lt;/noscript&gt;

{% spaceless %}&lt;noscript&gt;&lt;img src="{{ srcImage }}" alt="{{ alt }}" /&gt;&lt;/noscript&gt;{% endspaceless %}

{% autoescape false %}
&lt;noscript&gt;
  &lt;img
    src="{{ srcImage }}"
    alt="{{ alt }}"
  /&gt;
&lt;/noscript&gt;
{% endautoescape %}

{% autoescape false %}&lt;noscript&gt;{% endautoescape %}
{% autoescape false %}
  &lt;img
    src="{{ srcImage }}"
    alt="{{ alt }}"
  /&gt;
{% endautoescape %}
{% autoescape false %}&lt;/noscript&gt;{% endautoescape %}
</code></pre>

<templating>
Twig include with noscript tag rendered as a string and not code
# Twig include with noscript tag rendered as a string and not code

(Asked by: username_0 on 2018-03-22)

So I have an include file.

  


I am including like standard:
{% include '_includes/partials/image-noscript' %

but for some reason it is generating the code like so…

  <img
    src="http://plowmancraven-v4.loc/imager/uploads/images/general/3172/PC-Enviro-Generic-London-shutterstock_370946690_3488bcae28a5a46889970c4f238b0c7c.jpg"
    alt="PC Enviro Generic London"
  />


Edit: Here are some of the things I have tried but nothing has solved this issue yet.
{%- include '_includes/partials/image-noscript' -%}
{% autoescape false %}{% include '_includes/partials/image-noscript' %}{% endautoescape %}

inside the included file:


{% spaceless %}{% endspaceless %}

{% autoescape false %}

  

{% endautoescape %}

{% autoescape false %}{% endautoescape %}
{% autoescape false %}
  
{% endautoescape %}
{% autoescape false %}{% endautoescape %}

**Tags:** templating


---

## 1 answers

### Answer by username_1 on 2018-03-22. Score: 4

It's escaping the text in the default (html) context, which should not be happening for a template you include
I suspect this is due to a larger issue, as templates that are included should not be escaped in this manner.
You can change the escaping strategy using block tags around the code, though:
{% autoescape false %}
{% endautoescape %}

cf: autoescape

> **Comments:**
> **username_0**: Unfortunately this hasn't resolved the issue. I have updated my original question with the variations I have tried. Any other ideas would be appreciated.  
> **username_1**: If that doesn't work, something else is deeply wrong here.  

---

