django-sphinx-view
django-sphinx-view copied to clipboard
Allow per-page templates.
Follow-up to #12/#15 — adding global TOC.
By setting file-wide metadata, before any other markup:
:page_template: sphinx_view/no-globaltoc.html
… it's possibly to switch the template used to render each page, for example to not show the global TOC, on the index page, where it's already defined.
assert doc["meta"]["page_template"] == "sphinx_view/no-globaltoc.html"
- Store the result of
get_doc_json()onself. (As a@property? 🤔) - Re-use that in
get_template_names()to see ifdoc["meta"]["page_template"]is set.
- Use that if so.
- Otherwise, self.template_name, as usual.