I have a snippet within a template which I want to pass a variable into:
page.twig
{% set lightswitchTest = entry.aktivesProjekt('1').find() %}
{% include '_snippets/thingy' %}
thingy.twig
<div class="panel{% if lightswitchTest == null %} notActive{% endif %}">
{# bla bla #}
</div>
I tried to add pass in the variable with the with keyword but I guess my syntax is wrong?
{% include '_snippets/thingy' with lightswitchTest %}
If i use the varibale now in the snippet there is just the Array to string conversion error.
What am I missing? Is there a better way?
onlyparameter, if you want to exclude other variables from being exposed to the included template:{% include "_snippets/thingy" with { active: lightswitchTest } only %}– Mats Mikkel Rummelhoff Oct 24 '16 at 15:31