Skip to main content

Introduction

Sometimes static configuration files and templates are not enough to solve the real-life problems we might face. To help overcome those trickier challenges and avoid tedious and error-prone manual work, Takomo supports dynamic templating with Handlebars and EJS. You can choose which templating engine you want to use, or you can even implement your own.

All standard Handlebars features are available, which means you can use loops, if-conditions, partial includes, helpers, and variables to streamline your configuration.

By default, Takomo processes all stack configuration, stack group configuration, and stack template files using templating engine.

note

You can turn off dynamic processing of stack template files by setting dynamic to false under the stack's template property.

Choosing templating engine

By default, Takomo uses Handlebars, but you can choose to use EJS with templateEngine property in takomo.yml file.

templateEngine: ejs

Understanding dynamic templating

It's essential to understand how dynamic templating works with Takomo. Takomo processes configuration files with templating engine before parsing their content. The output produced by the processing needs to be a valid YAML document.

The YAML standard has some gotchas which may cause unexpected behaviour especially if you generate configuration files dynamically using templating engine. It's helpful to set the logging level to trace when troubleshooting YAML-related problems.