在把手中寻找助手

时间:2015-09-07 07:36:34

标签: handlebars.js

我有一个'国家'对象,我将其作为Handlebars上下文的一部分传递:

{
 'hk': {'name': 'Hong Kong', 'someotherprop': 'someothervalue'},
 'us': {'name': 'United States',  'someotherprop': 'yetanothervalue'},
 ...
}

我想使用查找Handlebar助手从国家代码'hk'中找到'香港'这个名字。

我可以得到以下对象

{'name': 'Hong Kong', 'someotherprop': 'someothervalue'}

使用以下Handlebars指令

{{lookup ../countries countrycode}}

但我现在如何从此对象中提取name属性?

1 个答案:

答案 0 :(得分:8)

显然,可以使用子表达式语法链接查找调用

{{lookup (lookup ../countries countrycode) 'name'}}
相关问题