AKRAM EL HAMDAOUI
AKRAM EL HAMDAOUI

Reputation: 1838

Setting rendered response into a variable twig Symfony2

I have a controller function which return a response with a value, and I want to call this controller from twig so I use:

 {% render "UaePortailBundle:Note:isRempli" with { 'module_id' : module.id , 'year' : year } %} 

the problem is that I want to set this returned value into a variable "x"

I tried this, but it doesn't work.

 {% set x = {% render "UaePortailBundle:Note:isRempli" with { 'module_id' : module.id , 'year' : year } %} %}

Upvotes: 2

Views: 2470

Answers (1)

egeloen
egeloen

Reputation: 5874

According to the documentation, you can do:

{% set x %}
    {% render "UaePortailBundle:Note:isRempli" with { 'module_id' : module.id , 'year' : year } %}
{% endset %}

Upvotes: 6

Related Questions