Refactor "document from template" view

/cc @phgross