Data as JSON object
Renders a Handlebars template with the object in data.
Input
{
"template": "{{#each peopleData}}<div class='person'><h2>{{name}}</h2><p><strong>Age:</strong> {{age}}</p><p><strong>Occupation:</strong> {{occupation}}</p><p><strong>Email:</strong> {{email}}</p></div>{{/each}}",
"data": {
"peopleData": [
{
"name": "John Smith",
"age": 32,
"occupation": "Software Engineer",
"email": "john.smith@example.com"
},
{
"name": "Jane Doe",
"age": 27,
"occupation": "Marketing Manager",
"email": "jane.doe@example.com"
}
]
},
"noEscape": false,
"preventIndentation": true
}Output · HTTP 200
{
"result": "<div class='person'><h2>John Smith</h2><p><strong>Age:</strong> 32</p><p><strong>Occupation:</strong> Software Engineer</p><p><strong>Email:</strong> john.smith@example.com</p></div><div class='person'><h2>Jane Doe</h2><p><strong>Age:</strong> 27</p><p><strong>Occupation:</strong> Marketing Manager</p><p><strong>Email:</strong> jane.doe@example.com</p></div>"
}Show curl command
curl -X POST 'https://api.1001fx.com/data/template2text' \
-H 'X-API-KEY: YOURSECRETAPIKEY' \
-H 'Content-Type: application/json' \
-d '{"template":"{{#each peopleData}}<div class='\''person'\''><h2>{{name}}</h2><p><strong>Age:</strong> {{age}}</p><p><strong>Occupation:</strong> {{occupation}}</p><p><strong>Email:</strong> {{email}}</p></div>{{/each}}","data":{"peopleData":[{"name":"John Smith","age":32,"occupation":"Software Engineer","email":"john.smith@example.com"},{"name":"Jane Doe","age":27,"occupation":"Marketing Manager","email":"jane.doe@example.com"}]},"noEscape":false,"preventIndentation":true}'