0
votes

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 ...

1
I can't find tag trans here: twig.sensiolabs.org/doc/templates.htmlOZ_
twig.sensiolabs.org/doc/extensions/i18n.html It works without the IF around it...Joseph Tura
Thanks, I think I will use it :)OZ_

1 Answers

2
votes

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