Design
Loop over object properties
Repeat any part of your document from object properties
COMMUNITY FEATURE
Available for:
Carbone Cloud
Carbone On-premise
Embedded Carbone JS
v3.0+
Iterate over object properties
- use
.attto print the attribute - use
.valto print the value
{
"myObject" : {
"paul" : "10",
"jack" : "20",
"bob" : "30"
}
}
People namePeople age{d.myObject[i].att}{d.myObject[i].val}{d.myObject[i+1].att}{d.myObject[i+1].val}
People namePeople agepaul10jack20bob30
Read and loop over the same object
To print a property of an object directly, such as {d.myObject.paul}, and also loop over the same object with {d.myObject[i].att} in the same template, add the pre-release tag {o.preReleaseFeatureIn=5004002} to the template. Without it, the generation fails. See all pre-release tags.
{
"myObject" : {
"paul" : "10",
"jack" : "20",
"bob" : "30"
}
}
{o.preReleaseFeatureIn=5004002}Paul is {d.myObject.paul} years old.People namePeople age{d.myObject[i].att}{d.myObject[i].val}{d.myObject[i+1].att}{d.myObject[i+1].val}
Paul is 10 years old.People namePeople agepaul10jack20bob30