Rewrite template mechanism.