0

I am using Twig to conditionally display a piece of HTML (or trying to, anyway).

What is wrong with this? Everything works okay until I put in the if-endif pair.

{% set numberOfPartners = partners|length %} (% if numberOfPartners > 1 || partners[0].special != 1 %} <div id="headline"> {% trans %} Lorem ipsum dolor {{ numberOfPartners }} <br /> {% endtrans %} </div> {% endif %} 

The error I get is

Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'Unknown tag name "endif" in ...

3

1 Answer 1

2

I haven't actually looked at the code or tested it, but is it because you've got (% instead of {% on line 2?

Sign up to request clarification or add additional context in comments.

2 Comments

Believe it or not, I have been staring at my code for about half an hour and did not see that. You saved me. I am going to delete this stupid question ;) Maybe it's time I turn my machine of for the day.
Ha, we've all spent hours on that accidentally-capitalized letter or missing semicolon! And I wouldn't delete it... That error message isn't very helpful (should probably say something like "unmatched 'endif' tag"), so someone searching for "Unknown tag name 'endif'" might find their answer here too.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.