Pass javascript variable to twig
for (varJS = 0; varJS < 5; varJS++) {
var url = '{{ path("lesson", {'id': 'article_id'}) }}';
url = url.replace("article_id", varJS);
text += '<a href='+ url +'>article</a>';
}
Note You should really look at the FOSJsRoutingBundle.
According to Chalasr's answer.
I've done this thrick using :
<script>
var your_js_variable = 5;
`{{ path("deletePFTaxeSpeciale",{'id' : 'idCarburant' }) }}`.replace('idCarburant', your_js_variable)
<script>