Use Javascript to access a variable passed through Twig

前端 未结 4 1691
南旧
南旧 2020-11-28 09:24

I have a controller that passes an array to a twig template, which I want to use in a script written on that page. How would I go about doing that?

I\'ve tried this

4条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 10:20

    You might have to json_encode the array, try this:

    
    

提交回复
热议问题