Trouble passing a string from an array to a variable within a for loop
<p>Im setting a "category" and passing it to a template that I'm including: </p>

<pre><code>    {% set categoryA = {
      category: "categoryA",
    }
    %}

    {% include "something.twig" with categoryA %}


    {% set categoryB = {
      category: "categoryB",
    }
    %}

    {% include "something.twig" with categoryB %}
</code></pre>

<p>This is working fine but I'm repeating a lot of code which I want to avoid (in my actual code there are more than 2 categories).</p>

<p>Im trying to put the categories in an array and include something.twig for each one, passing a different category for each instance: </p>

<pre><code>    {% set categories = ['categoryA', 'categoryB', 'categoryC', 'categoryD', 'categoryE'] %} 


    {% for i in categories %}

      &lt;h3&gt;{{ i }}&lt;/h3&gt;

      {% set categoryOption = {
        category: {{ i }},
      }
      %}

      {% include "something.twig" with categoryOption %}

    {% endfor %}
</code></pre>

<p>The title in the h3 is printed OK however the categoryOption category is passed as [object Object] rather than the string name as I need</p>