It would be easy to convert the structure from an object to an array as a workaround, but pug should handle both
The code above fails with the following error:
var err = new Error(fullMessage);
^
Error: Pug:4:32
2| p Offerings
3|
> 4| each offering, key in offerings
--------------------------------------^
5| h2= offering.title
6| p= offering.description
7| p= offering.price
The value variable for each must either be a valid identifier (e.g. `item`) or a pair of identifiers in square brackets (e.g. `[key, value]`).
at makeError (/pug_bug_of/node_modules/pug-error/lib/index.js:34:15)
at Lexer.error (/pug_bug_of/node_modules/pug-lexer/index.js:62:15)
at Lexer.eachOf (/pug_bug_of/node_modules/pug-lexer/index.js:1108:14)
at Lexer.callLexerFunction (/pug_bug_of/node_modules/pug-lexer/index.js:1647:23)
at Lexer.advance (/pug_bug_of/node_modules/pug-lexer/index.js:1676:12)
at Lexer.callLexerFunction (/pug_bug_of/node_modules/pug-lexer/index.js:1647:23)
at Lexer.getTokens (/pug_bug_of/node_modules/pug-lexer/index.js:1706:12)
at lex (/pug_bug_of/node_modules/pug-lexer/index.js:12:42)
at Object.lex (/pug_bug_of/node_modules/pug/lib/index.js:104:9)
at Function.loadString [as string] (/pug_bug_of/node_modules/pug-load/index.js:53:24) {
code: 'PUG:MALFORMED_EACH_OF_LVAL',
msg: 'The value variable for each must either be a valid identifier (e.g. `item`) or a pair of identifiers in square brackets (e.g. `[key, value]`).',
line: 4,
column: 32,
filename: undefined,
src: '\n' +
'p Offerings\n' +
'\n' +
'each offering, key in offerings\n' +
' h2= offering.title\n' +
' p= offering.description\n' +
' p= offering.price\n' +
" a(href='https://example.com/offering/' + key) More info\n",
toJSON: [Function (anonymous)]
Pug Version: 3.0.3
Node Version: 18.12.1
Input JavaScript Values
Additional Comments
This issue seems related to or possible the same as this other closed issue: https://github.com/pugjs/pug/issues/3263
It would be easy to convert the structure from an object to an array as a workaround, but pug should handle both
The code above fails with the following error: