First pass at dynamic template picker. See #780