-
Notifications
You must be signed in to change notification settings - Fork 1
Merge
Jair Andres Diaz Puentes edited this page Mar 15, 2018
·
1 revision
You can merge multiple objects into a single object using the #merge operator. If there are any overlapping attributes, the ones that come later will override the previously set attribute.
var data = {
numbers: [1,2,3],
align: "right",
size: "14"
};
var template = {
"{{#merge}}": [
{
"type": "label",
"text": "Length: {{numbers.length}}"
},
{
"style": {
"align": "{{align}}",
"size": "{{size}}"
},
"action": {
"type": "$render"
}
}
]
};
Select and transform
ST.select(template)
.transform(data)
.root();
Get the result
{
"type": "label",
"text": "Length: 3",
"style": {
"align": "right",
"size": "14"
},
"action": {
"type": "$render"
}
}