Design

The basics

Learn how to use a simple Carbone placeholder tag
COMMUNITY FEATURE Available for:
Carbone Cloud
Carbone On-premise
Embedded Carbone JS
  v1.0+ 

Each part of the documentation shows exactly what happens if you send Data (JSON Object) and a Template (handmade docx, odt, ...) to Carbone.

Basic

Carbone tags are placeholders {d.} within the template, then they are replaced with data from your JSON dataset. The value can be a string, a number, or a date.

data
{
  "firstname": "John",
  "lastname": "Doe"
}
template
Hello {d.firstname} {d.lastname} !
Carbone Merge Icon
result
Hello John Doe !

Accessing sub-objects

If a dataset contains sub-objects, Carbone can access them using the Dot Notation to go deeper in the object tree.

data
{
  "firstname": "John",
  "type": {
    "id": 1,
    "name": "human"
  }
}
template
{d.firstname} is a {d.type.name}
Carbone Merge Icon
result
John is a human

Accessing arrays

When data is an array of objects, you can access directly each object using the reserved word i, which represents the ith item of the array. Carbone uses zero-based arrays:

An array is reachable using the Square Bracket Notation [].

data
[
  { "movie": "Inception" },
  { "movie": "Matrix" },
  { "movie": "Back to the future" }
]
template
Preferred movie are {d[i=1].movie} and {d[2].movie}
Carbone Merge Icon
result
Preferred movie are Matrix and Back to the future

Parent properties

Access properties of the parent object with two points .. (or more)

data
{
  "country": "France",
  "movie": {
    "name": "Inception", 
    "sub": {
      "a" : "test"
    }
  }
}
template
{d.movie.sub..name}{d.movie.sub...country}
Carbone Merge Icon
result
InceptionFrance