Install
Follow the link below to learn more about the Handlebars Pack for Coda and install it. You can also type /Handlebars into any Coda doc.
Usage
The primary formula in the Pack is TemplateReplace(), which takes as parameters the template text and the placeholder values.
TemplateReplace("Hello {{name}}, welcome to {{place}}!",
"name", "Alice",
"place", "Earth")
= "Hello Alice, welcome to Earth"
For more complex usage you can pass the replacement values as a string of JSON and use the alternative TemplateReplaceWithJSON() formula.
TemplateReplaceWithJSON("Hello {{person.name}}, welcome to {{planet.title}}!",
'{"person": {"name": "Alice"}, "planet": {"title": "Earth"}}')
= "Hello Alice, welcome to Earth"
There is also a Placeholders() formula which will return a list of placeholders present in a template.
To learn more about the Handlebars templating language, check out this documentation.
Demo
The demo below demonstrates how to define templates and use those templates in with real values.