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)
I followed the pattern as seen elsewhere, for consistency :) If we consider a regexp-based endswith check better, we should use it everywhere IMHO (and add to a new BestCodingPractices.md)