question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Move layout/sidebar into `frame.html.jinja2`

See original GitHub issue

Problem Description

In my pdoc-powered site, I wished to combine elements of pdoc and non-pdoc content on the same pages. In order to do this, I had to set the ‘module’ variable, even though it didn’t make sense in this context. It is possible to work around, but somewhat awkward.

Proposal

Go through the code and find every place that module is used, and ensure that the code would work with a null object instead. This might perhaps be limited to the nav part of the template (leaving the main part of the template breaking if module isn’t an actual value, which kinda makes sense).

Alternatives

  1. I was able to work around this need by creating a dummy module object and passing that in to template.render. If there isn’t enough interest, we can just leave it at that.
  2. One might also consider re-arranging the default template hierarchy so that there was a page type “above” module.html.jinja2 that doesn’t require the module variable to be set, and have `module.html.jinja2’ (and ‘index.html.jinja2’) inherit from that. This would make sense, but it would probably also be a breaking change, so perhaps not a good idea.

Additional context

You can see the site I have created at https://projectdrawdown.github.io/solutions/. I want to have the nav on all pages, even those that aren’t module pages, and thus needed to do the workaround.

Also, I am willing to do this work, if it seems worthwhile.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
denisedcommented, Feb 18, 2022

I had the same issue @abubelinha – You probably define your own {% block nav %}. Inside that, you need to remove the outer level <nav> element, which is now part of the frame template, and leave just the contents.

1reaction
denisedcommented, Feb 9, 2022

Honestly I’d rather leave refactoring like that to you — I’m sure your sensitivity to fine feature details will be better than mine on this 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Template Designer Documentation - Jinja
This document describes the syntax and semantics of the template engine and will be most useful as reference to those creating Jinja templates....
Read more >
How do I include a HTML file in a Jinja2 template?
I tried to encapsulate two html files in a list [% include ['content1.html, content2.html ]', but this too is not working only it...
Read more >
Primer on Jinja Templating - Real Python
When you use Jinja's template inheritance, you can move the common structure of your web app to a parent base template and let...
Read more >
Render Pages in Flask Using Jinja2 Templates
Changing a navigation link meant manually making the same change across hundreds of ... Unlike static HTML, templating systems like Jinja empowers us...
Read more >
pdoc/module.html.jinja2 at main · mitmproxy/pdoc - GitHub
This macro is a bit unconventional in that its output is not rendered, but treated as a boolean: Returning no text is interpreted...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found