-
Notifications
You must be signed in to change notification settings - Fork 1
Loop
Jair Andres Diaz Puentes edited this page Mar 15, 2018
·
2 revisions
Use #each to iterate through items
var template = {
"orders": {
"{{#each customers}}": {
"order": "One {{menu}} for {{name}}!"
}
}
}
var data = {
"customers": [{
"name": "Hatter",
"menu": "miso ramen"
}, {
"name": "March Hare",
"menu": "tonkotsu ramen"
}, {
"name": "Dormouse",
"menu": "miso ramen"
}, {
"name": "Alice",
"menu": "cup noodles"
}]
}
Select and transform
ST.select(template)
.transform(data)
.root();
Get the result
{
"orders": [{
"order": "One miso ramen for Hatter!"
}, {
"order": "One tonkotsu ramen for March Hare!"
}, {
"order": "One miso ramen for Dormouse!"
}, {
"order": "One cup noodles for Alice!"
}]
}