Fixed template scripting compiler

Fixes #1088