Initial implementation of CompileTemplate