template: Allow document objects to be passed