I'm afraid this is not possible. Templates can only be defined at global/module scope, but the code inside a diet template is internally always inserted at function scope.

huh! Thanks!