HTMX + Flask: Modern Python Web Apps, Hold the JavaScript Transcripts
Chapter: HTML template partials
Lecture: What do you mean by partials?

Login or purchase this course to watch this video and the rest of the course contents.
0:00 "Click to Edit" was super cool,
0:02 wasn't it? But it started to reveal a problem that Flask by itself is not
0:07 well designed to deal with. That is, we need to show the entire page with some
0:12 element of HTML, and then we need to show a partial part of that page or
0:18 just that fragment of HTML again in a different view.
0:22 Remember we had that ads button to add a video which would then reveal the form?
0:27 We had to have that in two different locations and that's clearly error-prone and
0:32 not a good idea. So what we're gonna do in this chapter is take a
0:35 little diversion and talk about an open source package I created for Flask and really any
0:42 library that uses Jinja called Jinja Partials.
0:45 Now, Jinja Partials is kind of like adding functions to HTML.
0:49 We can go to any part of our template,
0:53 pass it along data to one of these sub templates and it will render inside of that
0:58 template as well as being able to treat that piece completely separately and isolated and return
1:04 it back directly from a view for the htmx interaction side of things.
1:08 Some people think this is similar to Jinja's include or sometimes Jinja's macro features.
1:16 It's definitely not the macro feature, that's completely different.
1:20 This has a whole new feature,
1:22 like include, it is similar, but it has more functionality to structure the way the
1:26 data is passed over to sub templates.
1:29 So I think it's pretty unique, and it's going to generate incredibly clean code on the
1:35 HTML template side. It allows to reuse it exactly the way we need to for
1:40 htmx. We're not gonna do htmx in this chapter yet.
1:43 That's the next one. But this is the groundwork to having clean code with htmx