The {{ array_get }}
tag simplifies outputting data nested in arrays. It shines when one or more of those keys are stored in a variable.
While the examples all use front-matter variables, this tag works with any array-type variables. Using front-matter is simply the easiest way to illustrate the concept.
For context, assume these two fields exist:
- a Video field called
video
- a Radio field called
size
with the optionsfull_width
,large
,medium
, andsmall
Sample blueprint excerpt
sections:
main:
display: Main
fields:
-
handle: My Grid
field:
type: grid
sets:
video:
fields:
-
handle: video
field:
type: video
-
handle: size
field:
options:
full_width: Full-width
large: Large
medium: Medium
small: Small
type: radio
default: full_width
In a partial, I added an array to the front matter for the different variants' settings. Each key maps to one of the options from the size
field.
Dot-syntax key-path to the value.
You only need the key
param if one or more keys in the path come from a variable. For me, this often comes from user-generated content or a parameter passed to the partial.
This value serves as the fallback if the key-path doesn't exist.