Export Functions of Template Libraries
Exported functions are the interface a template library offers; strategies that reference the template library can call them. How each language exports them is described in Template Library.
Examples
Declare and implement the exported function Test in a template library, in each language.
javascript
/*
-- after referencing this template, a strategy calls this method directly as $.Test()
-- main is never triggered in the strategy; it is only the entry point for debugging the template
*/
$.Test = function() {
Log('Test')
}
function main() {
$.Test()
}
python
def Test():
Log("template call")
# export Test; the main strategy calls it as ext.Test()
ext.Test = Test
rust
// after referencing this template, a strategy calls it as ext::Test()
// functions called by the strategy must be declared pub
pub fn Test() {
Log!("template call");
}