How to assign templates by document type