【发布时间】:2020-04-21 18:59:30
【问题描述】:
这个问题只是在我将代码迁移到生产环境时才出现的,在我的开发环境中不会发生。
我有一个接收对象的车把模板,例如:
{node: {sections: [{name: 'abc'},{name: 'xyz'}]}}
模板如下所示:
{{#each node.sections}}
{{#ifCond type '==' "image-left-text-right"}}
{{> admin/section/image-left-text-right}}
{{/ifCond}}
{{#ifCond type '==' "two-columns-image-and-text"}}
{{> admin/section/two-columns-image-and-text}}
{{/ifCond}}
{{#ifCond type '==' "four-columns"}}
{{> admin/section/four-columns}}
{{/ifCond}}
{{/each}}
现在这一切在我的开发环境中看起来都很棒,并且模板正确呈现,在生产中没有任何显示。
在控制台记录我的整个对象后,我可以确认它在那里,写了一个小助手来帮助我控制台记录它:
<script>
console.log('----1---')
console.log({{{json node}}})
console.log('----2---')
console.log({{{json node.sections}}})
console.log('----3---')
</script>
但是第二个控制台日志什么也没输出。
好像它无法访问对象上的那个属性?
我在 dev 和 prod 中都运行版本 handlebars@4.7.6。在我需要设置的 Handlebars 中是否有一些我不知道的奇怪的私有/公共标志,以允许它直接访问数组?
【问题讨论】:
标签: node.js handlebars.js