<p>It appears to be due to the angle brackets. Try:</p>

<pre><code>&lt;script&gt;
    var homepageStandfirstAnchors = [{% for anchor in homepage.homepageStandfirstAnchors %}[{{ anchor.text }},{{ anchor.section.handle }},{{ anchor.anchorLink }}],{% endfor %}];
&lt;/script&gt;
</code></pre>

CC BY-SA 3.0
2014-09-25T10:56:22.730Z
DUH whoops. I'll delete this question but thanks!
Daniel
CC BY-SA 3.0
2014-09-25T10:36:55.680Z
2014-09-25T10:36:55.680Z
Shane Hudson
<p>I think I might be missing something here but it seems twig tags aren't parsed within  tags? Is there any way they can be, e.g.:</p>

<pre><code>&lt;script&gt;
var homepageStandfirstAnchors = [&lt;% for anchor in homepage.homepageStandfirstAnchors %&gt;[{{ anchor.text }},{{ anchor.section.handle }},{{ anchor.anchorLink }}],&lt;% endfor %&gt;];
&lt;/script&gt;
</code></pre>

<p>doesn't work as expected.</p>

CC BY-SA 3.0
2014-09-25T10:56:58.670Z
My bad - should have been {% not <%
Daniel
<templating><javascript>
Twig templating within <script> tag
# Twig templating within <script> tag

(Asked by: username_0 on 2014-09-25)

I think I might be missing something here but it seems twig tags aren't parsed within  tags? Is there any way they can be, e.g.:


doesn't work as expected.

**Tags:** templating, javascript
> **Comments:**
> **username_0**: My bad - should have been {% not <%  

---

## 1 answers

### Answer by username_1 on 2014-09-25. Score: 1 | Accepted answer

It appears to be due to the angle brackets. Try:

> **Comments:**
> **username_0**: DUH whoops. I'll delete this question but thanks!  

---

