Building Data-Driven Web Apps with Flask and SQLAlchemy Transcripts
Chapter: Course conclusion
Lecture: Layout pages
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
We saw that when we create our HTML page
0:03
we've got a bunch of CSS, JavaScript
0:06
other settings, meta tags, all that kind of stuff
0:09
maybe even navigation bars and footers.
0:11
We want that shared across all the different pages.
0:14
So instead of replicating it
0:16
which would be a terrible idea
0:17
we saw that we can use the extends
0:20
and create these blocks and fill them in.
0:22
So we can create a Jinja2 template
0:24
and we can say that our page template
0:27
extends this shared layout template.
0:30
Remember how we organized our template files as well?
0:32
We had a template folder
0:33
and then there're a folder for each view module
0:36
that we're going to put together
0:37
like account and packages and so on.
0:40
Then we also had a shared one
0:41
and that's where we put our shared layout.
0:42
You don't have to do that, but you know you probably should.
0:45
It will really help you in the end.
0:47
So anyway, you definitely, definitely want to make sure
0:49
that you use this share layout.
0:50
It makes maintaining the site really much easier
0:53
and it's great. Definitely do it. Very easy in Flask.