I have a problem accessing json keys with whitespaces or spacebars inside in pug for each loops. Backticks, single and double quotes didn't work for me so I had to fall back to this.
.pug file
for element in aJson
for value, key in element
if key == "my key with spaces"
|
=value
Is there any other workaround that is cleaner or did I miss something? I use tabs for indentation in my .pug files. I'm using version 3.0.0 (https://www.npmjs.com/package/pug)
the following does not work:
.pug file
for element in aJson
|
=element.`my key with spaces`
----> syntax error
for element in aJson
|
=element.my key with spaces
-----> "my" not found error
my json file looks like this:
{
"Element": [
{
"my key with spaces": "Value 1",
"Key2": "Value 2",
"Key3": "Value 3",
"Key4": "Value 4",
"Key5": "Value 5"
},
],
"Element2": [
{
"my key with spaces": "Value 1",
"Key2": "Value 2",
"Key3": "Value 3",
"Key4": "Value 4",
"Key5": "Value 5"
},
],
...
}