Search code examples
expresshandlebars.jsexpress-handlebars

can i use 'this' operator in express-handlebars as array index in the same express-handlebars?


{{@root.comments.[this.[0]].[0]._id}}

Error: Parse error on line 96: ...t.comments.[this.[0]].[0]._id}}:5:31) at prog (/home/nkhil/Nikhil/test-handlebar/node_modules/handlebars/dist/cjs/handlebars/runtime.js:221:12) at execIteration (/home/nkhil/Nikhil/test-handlebar/node_modules/handlebars/dist/cjs/handlebars/helpers/each.js:51:19)


can anybody please help me ?

Thanks in advance


Solution

  • No you can't do that. It's not a valid expression in handlebars. Try to save the state instead of using this operator.