Move document access into TemplateContext so it can be used in partials as well