In chemistry, a template reaction is any of a class of ligand-based reactions that occur between two or more adjacent coordination sites on a metal center.  In the absence of the metal ion, the same organic reactants produce different products. The term is mainly used in coordination chemistry. The template effects emphasizes the pre-organization provided by the coordination sphere, although the coordination modifies the electronic properties (acidity, electrophilicity, etc.) of ligands.
An early example is the dialkylation of a nickel dithiolate:
The corresponding alkylation in the absence of a metal ion would yield polymers.  Crown ethers arise from dialkylations that are templated by alkali metals.  Other template reactions include the Mannich and Schiff base condensations. The condensation of formaldehyde, ammonia, and tris(ethylenediamine)cobalt(III) to give a clathrochelate complex is one example. 
The phosphorus analogue of an aza crown can be prepared by a template reaction. Where it is not possible to isolate the phosphine itself.