-
Notifications
You must be signed in to change notification settings - Fork 346
Description
I find the sidebar templating logic to be a bit confusing to wrap my head around. I wonder if it could be made a little bit more modular if we generated that HTML with a Python function. E.g., I feel like we must be able to generate that structure with a recursive function, similar to how we parse the nav items on the page.
Maybe this would be easier than having a bunch of if/then statements in the Jinja itself? I tried making a little demo function, and if we pass it nav like so:
{{ my_func(nav) }}
then nav has this structure:
[{'active': False,
'children': [],
'title': 'User Guide',
'url': '../user_guide/index.html'},
{'active': False,
'children': [],
'title': 'Contributing',
'url': '../contributing.html'},
{'active': True,
'children': [{'active': False,
'children': [],
'title': 'Structural Elements',
'url': 'structure.html'},
{'active': False,
'children': [],
'title': 'Paragraph Level Markup',
'url': 'demo.html'},
... and so on
So it might be easy to loop through that and recursively generate the right HTML. Do you think this is worth a shot? Or am I over-thinking this?
(one reason I'm interested in this is to make it easier to switch back-and-forth between "sidebar + topbar" and "only sidebar" layouts)