Handlebars.js parse object instead of [Object object]

前端 未结 5 623
囚心锁ツ
囚心锁ツ 2020-11-27 16:20

I\'m using Handlebars templates and JSON data is already represented in [Object object], how do I parse this data outside of the Handlebars? For example, I\'m trying to popu

5条回答
  •  粉色の甜心
    2020-11-27 17:06

    I'm using server-side templating in node-js, but this may apply client-side as well. I register Jonathan's json helper in node. In my handler, I add context (such as addressBook) via res.locals. Then I can store the context variable client-side as follows:

    
    

    Note the triple curlies (as pointed out by Jim Liu).

提交回复
热议问题