Migrated document creation to use the template system, closes #14.

The template system required more work but the current functionality is
sufficient for many use cases so also closes #17.