Fixed exporting of template

Fixes #1506