Making template functions persist between templates