How to pass an object to a .handlebars template and use it in a javascript code block?
问题 server.js: app.get('/home', function (req, res) { data['one'] = "first"; data['two'] = "secound"; res.render('home', { data }); }); home.handlebars: <script type="text/javascript"> var data = { {{{data}}} }; console.log(data.one); </script> Browser Console Error: Uncaught SyntaxError: missing ] in computed property name How can I pass the object to use it in .handlebars template within a script code block? 回答1: I think there a few things we need to review in order to arrive at a solution.