In Foundry's Slate application, I'd like to index into an array or other object based upon some seletion in another widget -- say, choosing a column from a dropdown.
How can I accomplish something like this?
In Foundry's Slate application, I'd like to index into an array or other object based upon some seletion in another widget -- say, choosing a column from a dropdown.
How can I accomplish something like this?
Copyright © 2021 Jogjafile Inc.
You can use the lookup handlebars helper reference.
The lookup helper looks like the following {{lookup arrayName index}} and is equivalent to arrayName[index] in javascript.
This also works for objects as
{{lookup objectName key}}
.And you can do it for nested things as well:
{{lookup a "b" "c"}}
where the context is
{ a: { b: { c: "test" } } }
Will return
"test"
To simplify things, you can also write a small helper function that takes in the selection and the data, does any necessary work to produce the correct output and then returns that output to display elsewhere.