how do templates work