Reputation: 31
I have two twig template : full_view.html.twig has this
{% set price2 = opttov.smoptprice|split('.') %}
...
{{ price2.0|default('E') }}
{{ price2.1|default('00') }}
i want to include the full_view.html.twig
file in sale.html.twig
and change the value of price2
, to something like price2 = opttov.price|split('.')
.
i wrote in sale.html.twig this in for loop
{% for tov in item.tovar %}
{% include 'DevFarmUGDvorBundle:Catalog:_full_view.html.twig' with {'opttov':tov, 'opttov.smoptprice': tov.price} %}
{% endfor %}
doesnt work
Upvotes: 3
Views: 594
Reputation: 39390
You can construct the parameter for the include in this manner:
{% for tov in item.tovar %}
{%
set opttov = {'smoptprice' : tov.price }
%}
{% include 'DevFarmUGDvorBundle:Catalog:_full_view.html.twig'
with
{'opttov':opttov }
%}
{% endfor %}
Hope this help
Upvotes: 3