Support template mimetypes

Unless I forgot something the only difference between template versions and normal documents is the mimetype.

Fixes #744.
Fixes #746. (still not sure if this is the best API)
Seeing as ``"-template"`` is an important string, perhaps that could be in a const that is used throughout this function.

E.g.,: ``docMimtype.substr(-TEMPLATE_STR.length) === TEMPLATE_STR``
``docMimetype = docMimetype.substr(0, docMimetype.length-TEMPLATE_STR.length);``