0

Using nunjucks on Node

Have a for loop that iterates over an array without any problems if I use snake_case

{% for item in items.micro_release %} <li>{{ item.id }}</li> {% else %} <li>No items found...</li> {% endfor %}

As soon as I try to use kebob-case (for internal naming convention clarity only). It fails.

{% for item in items.micro-release %} <li>{{ item.id }}</li> {% else %} <li>No items found...</li> {% endfor %}

I am assuming that it is treating "-" as an arithmetic operator. Tried

set micro_release = "micro-release"

to force it to behave like a string. That didn't work.

Given its python origin, is nunjucks kebob-intolerant :)? jk. thnx in advance for any words of wisdom on this one.

dima
  • 870
  • 8
  • 10

1 Answers1

1

I am assuming that it is treating "-" as an arithmetic operator

I think too.
Try items['micro-release'].

Aikon Mogwai
  • 4,954
  • 2
  • 18
  • 31