Quiz
- could you please go over how to loop through get_flashed_messages() in jinja?
Sure. It's the same as any loop:
- For question 2, the directory technically has a CSS file within it, but not as a direct child (a grandchild). Is the question asking about direct children or if it's contained in the directory?
I was thinking of it as the larger containment, rather than the narrower. But I can see that this is ambiguous. I'll ask LTS about how I can adjust the grading.
- Is it possible to specify a different CSS file for a child template? If so, how?
Sure. The parent should have a block in the HEAD that the child can replace, putting an additional or different CSS file in there. (It's in the HEAD because that's where any LINK tags to external CSS files is supposed to be.)
If the child also wants to replace some content in the BODY, that's okay too. Just replace two blocks.
Parent:
And the child:
- So when using template inheritance, how can a child template keep the content from a parent block while also adding its own content, instead of completely replacing the block?
Interesting. There is a variable called
superthat you can use, which is the inherited content:I'd forgotten about this, probably because I've never used it. But I can see how it would be useful at times.
See super blocks
- Not really a question but before this course I've tried using 11ty to manage static pages and the way we're working with template files reminds me of that but contrasting it with Flask makes me appreciate how cool dynamic page generation is.
Very interesting!