I have a Symfony 2.1 version with a controller that returns the total of points. I am rendering this in my twig template as follows:

{%render "AdminBundle:Reports:getExpiringPoints" with {'id':dealer.id}%}

This prints the total points. I need to check that value and print it if the rendering value is greater that 0.

Is it possible in Symfony 2.1?

有帮助吗?

解决方案

i found that :

    {% set x %}
        {%render "AdminBundle:Reports:getExpiringPoints" with {'id':dealer.id}%}
    {% endset %}

{% if x> 0 %}
  //display
{% endif %}

and after you can use it. Tell me if it works

其他提示

You can check it directly in the controller or with twig :

{% if var > 0 %}
  //display
{% endif %}

Twig supports all of the standard logical operators ==, !=, <, >, >=, and <=.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top