2015-09-07 126 views
2

我有一個「國家」的對象,我傳遞的把手上下文的一部分:查找助手在車把

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

我想使用查找車把助手從COUNTRYCODE「香港」名義'找香港'。

我可以使用下面的把手指令

{{lookup ../countries countrycode}} 

得到以下對象

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

但我現在該如何提取此對象的name屬性?

回答

5

顯然,一個能鏈查找調用使用的子表達式語法

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

而且,如果你需要訪問多個屬性,例如'name'和'someotherprop',你可以使用'{{#with(lookup ../countries countrycode)}} {{name}} {{someotherprop}} {{/ with}}'http://stackoverflow.com /一個/1487413分之42520682 –