Template from file or uri

Following up #31

I tried to do as little ref(a|u)ctorage as possible, but to make any headway at all, I had to extract some classes from the CLI.