template2text - Create Text / HTML from Template and Data
Creates any text from template and given data. For example, dynamically generate HTML templates with data and logic, making it useful for building dynamic web applications. Based on Handlebars - see https://handlebarsjs.com/ for more details.
template
string
Template to be filled in with data. For expressions you can use the following syntaxes: {{ name }} and { { name } }. See handlebars documentation.
Example:
"{{#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
object
Data used to fill the template.
Example:
{
"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"
}
]
}
dataString
string
Stringified Data used to fill the template.
Example:
{"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
boolean
Set to true to not HTML escape any content.
preventIndentation
boolean
By default, an indented partial-call causes the output of the whole partial being indented by the same amount. This can lead to unexpected behavior when the partial writes pre-tags. Setting this option to true will disable the auto-indent feature.
Example: