Template: factor out things for dynamic template functions.