Command Reference CIB jsMerge
JavaScript Functions
Exporting Local Functions
Local functions and variables in a template can be exported using the following syntax:
{# this.exports.myFunc = function() { ... }}
{# this.exports.i = 42}
The function and the variable in the example above are also local within the template, but they are made available to all included templates as well. The function and the variable are protected for this template but can be overwritten in an included template. This only affects the function within the included template, not the function in the parent template that initially defined the function. This provides better write protection to functions like these.
This function, too, is referenced via this.myFunc(...), e.g. text(this.myFunc(...))