Twig for loop in template not rendering
-
I seem unable to get a for loop to run properly within the template for instantsearch, any ideas why this would be? It’s as if the view is loading too late?
here is the part of my code with the for loop.
<# if ( data.col_1 ) { #> <ul class="swatches"> <li class="two-color active"> <a class="tool" href="{{ data.permalink }}"> <span style="background-color: {{ data.col_1 }}"></span> <span style="background-color: {{ data.col_2 }}"></span> </a> </li> <# if ( data.swatches ) { #> {% set swatches = data.swatches %} {% for swatch in swatches %} <li class="two-color"> test </li> {% endfor %} <# } #> </ul> <# } #>
Here is front end output: https://gyazo.com/749de3c59ca1150acd3fffd8f86f2483
AS you can see its getting to the loop and then just printing out… I tried it with and without setting a data.swatches as a variable.
As a reference, this is the swatches array on Algolia. https://gyazo.com/ffdc8dcb825f16dc016ab604bebcfc00
Any support appreciated.
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Twig for loop in template not rendering’ is closed to new replies.