此代码应显示文档字段 first_name 和 last_name,而不是生成“未捕获错误:未知帮助器 'first_name'”错误:
# In Template.
{{#with doc}}
<p>{{first_name}} {{last_name}}</p>
{{/with}}
# Template 'doc' property.
_.extend Template.doc,
doc: -> Docs.findOne {_id: Session.get 'doc_id'}
如果我用 #each 和 find() 替换 #with 和 findOne() 它可以正常工作:
# In Template.
{{#each doc}}
<p>{{first_name}} {{last_name}}</p>
{{/each}}
# Template 'doc' property.
_.extend Template.doc,
doc: -> Docs.find {_id: Session.get 'doc_id'}
这篇文章建议#with 应该工作将返回单个对象的流星方法转换为车把的上下文
我正在使用流星 0.3.7