You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importpugfrom'pug';constofferings={offering01: {title: 'Offering 01',description: 'This is the first offering.',price: 100,},offering02: {title: 'Offering 02',description: 'This is the second offering.',price: 200,}};constpugTemplate=`p Offeringseach offering, key in offerings h2= offering.title p= offering.description p= offering.price a(href='https://example.com/offering/' + key) More info`;console.log(pug.render(pugTemplate,{offerings}));
Additional Comments
This issue seems related to or possible the same as this other closed issue: #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:
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)]
The text was updated successfully, but these errors were encountered:
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: #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:
The text was updated successfully, but these errors were encountered: