1

Im trying to do a simple for loop in twig:

{{% for category in ['Action','Drama','Comedy','Anime','Adults','Science fiction'] %}} <p class="lead"><a href="">{{category}}</a></p> {{% endfor %}} 

but twig is giving me this error message and I cant see why: Unexpected token "operator" of value "%" in MoviesBundle:Default:index.html.twig at line 129.

I try this way array['Action','Drama','Comedy','Anime','Adults','Science fiction'] with the same result. a little help will be nice. Thanks!

2 Answers 2

2

In for and endfor the curly brackets must be single:

{% for category in ['Action','Drama','Comedy','Anime','Adults','Science fiction'] %} <p class="lead"><a href="">{{category}}</a></p> {% endfor %} 
Sign up to request clarification or add additional context in comments.

Comments

0
{% for category in ['Action','Drama','Comedy','Anime','Adults','Science fiction'] %} <p class="lead"><a href="">{{category}}</a></p> {% endfor %} 

curly brackets should be single. double bracket is used only for printing the variable and arrays.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.