Turn template contexts into serializable objects