how to write templates