key
Key extracts a value from a map or slice by key path or index.
Key extracts a value from a map or slice by key path or index. Use dot notation to traverse nested maps.
Input
map array
Parameters
| # | Type | Required |
|---|---|---|
| 0 | string | yes |
Returns
any
Examples
Read a top-level field
Input
user = {"name": "Alice", "email": "[email protected]"}Template
{{ user | key:'name' }}Output
AliceRead a nested field with dot notation
Input
config = {"database": {"host": "db.local", "port": 5432}}Template
{{ config | key:'database.host' }}Output
db.localIndex into a list
Input
items = ["espresso", "latte", "macchiato"]Template
{{ items | key:0 }}Output
espressoHow is this guide?