Hi,
The example Python code should be unindented, or you see a different error?
Also, you can always import code in the python block.
With destinations you can specify a path to a python file, so the python block is not needed. But with template functions I've figured the $(python) call would be too crowded if we were passing explicit filename parameters.
But you can encapsulate the python code as well as a wrapper to the python code into a separate file.
Foobar.conf:
python {
from foobar import foobar_template_function
}
template-function foobar "$(python foobar)"
----------
Then you can use:
@include "Foobar.conf"
...
template("$(foobar)");
...
Unfortunately then template function declarations cant take parameters yet from the callsite, which may be a serious limitation in your use-case. But with a conceot above you can completely hide implementation details your actual config.