Rendering a template using Gulp, Nunjucks, and an Array

298 Views Asked by At

I have some html like this:

<code class="html">
      <div class="u-color-background-gray-100">
        <code>u-color-background-gray-100</code>
      </div>

      <div class="u-color-background-gray-300">
        <code>u-color-background-gray-300</code>
      </div>
</code>

I would like to render it using Gulp, gulp-nunjucks-render, and the array ['100', '300'].

ANSWER

This is the answer - but I'd like the give the credit to the person who helped me refine the question, pointed out the right components, and helped me with the syntax - so please officially answer it - and I will remove this inline answer - I have tested the below):

<code class="html">
   {% for item in ['100', '300'] %}
      <div class="u-color-background-gray-{{item}}>
        <code>u-color-background-gray-{{item}}</code>
      </div>
   {% endfor %}
</code>
0

There are 0 best solutions below