support applying both in-place and external template