Handlebars helpers are plain JavaScript functions you can invoke from your stack group and stack configuration, and template files.
Helpers are supported only when using Handlebars templating engine.
You register your own custom Handlebars helpers by adding .js files to helpers
dir.
Each file must export an object with the following properties:
name
= Helper name you use in configuration.fn
= Function to invoked when the helpers is invoked. Must not be asynchronous function.Here are some examples of different helpers.
This helper returns the current date and takes no arguments.
This is how you'd use it in your files:
And this is what the final rendered file looks like:
This helper accepts a single string argument and returns it converted in upper case.
This is how you'd use it in your files:
And this is what the final rendered file looks like:
This helper accepts two arguments and returns a boolean value indicating if the two arguments are equal.
This is how you'd use it in your files:
And this is what the final rendered file looks like assuming var.environment
is "prod":
You can provide additional directories from where Takomo should load helpers by using helpersDir
property in takomo.yml
. You can give a single path or list of paths. Paths can be absolute or relative to the current project directory. Regardless of additional helper locations, Takomo will always also look helpers from helpers
directory located under the current project directory.
Specify a single custom location for helpers.
Specify multiple custom locations.