Template Functions
FBL also provides few handy utility functions (JavaScript) you can use inside the template. They all assigned to '$' variable, so you can use them like this:
Template utilities just like action handlers are part of plugins. Some plugins may add their own handy functions.
Default Functions
File System
All the default action handlers are treating paths as relative to the directory where flow file is located. However in rare cases 3rd party plugins may not handle this right, to bypass that limitation just use following function to convert path:
You may also want to create a relative path based on the directory from where fbl
command was executed (might be handy for packaged flows):
There are also 2 utility functions to read the file. Note: both are not recommended to use, as they block the flow for the time they read the file. In other words they are blocking entire process and any other actions that are running in parallel will wait till this functions will be resolved.
UUID Generation
Both UUID v4 and v5 are supported.
Hash
Generate hash (as string) for given string.
Assign To
Assign value to context.
Note: first parameter is using same syntax as common assignTo syntax.
Push To
Assign value to context.
Note: first parameter is using same syntax as common assignTo syntax.
Assign To / Push To - JSON Schema generation
It might be handy to use $.assignTo()
/$.pushTo()
in pair with $.assignToSchema()
/$.pushToSchema()
function inside virtual. To generate action like virtual.
Virtual Example:
Include another template
Include another file as a template inside the flow.
Example:
Write to file based on the template that includes another file.
/tmp/template.ejs:
/tmp/fixture.ejs:
Last updated