Template expansion