Twig templating within  tag 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.:

&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;


doesn't work as expected.
It appears to be due to the angle brackets. Try:

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