Apply same mapping logic to dynamic templates...

... as is used for the normal mappings