fix bug in compile-templates