Using Custom Helpers
Sometimes it's useful to create your own custom helper functions that you can use during the template rendering process.
Use the --include
flag to specify one or more files containing helper functions.
Note
You can pass the --include
flag multiple times, or even use glob patterns to include multiple files.
Example
Below is a sample helper function. Let's see how to use it.
-
First, place this block inside a helper file (e.g.
helper.tmpl
) -
Then, pass
--include ./helper.tmpl
to therender
) command.
Finally, in order to invoke the custom helper function, use the {{ include ... }}
built-in function from your main template.
e.g.
The engine will render the say_hello
block separately, and include the output text wherever you put {{ include ... }}
function.
For this example, the final rendered text will look like this