Lookup helper in handlebars

别等时光非礼了梦想. 提交于 2019-12-08 00:22:02

问题


I have a 'countries' object which I pass as part of the Handlebars context:

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

I want to use the lookup Handlebar helper to find from the countrycode 'hk' the name 'Hong Kong'.

I can get the following object

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

using the following Handlebars directive

{{lookup ../countries countrycode}}

but how do I now extract the name property from this object?


回答1:


Apparently one can chain lookup calls using the subexpression syntax

{{lookup (lookup ../countries countrycode) 'name'}}


来源:https://stackoverflow.com/questions/32433381/lookup-helper-in-handlebars

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!