Full Web Apps with FastAPI Transcripts
Chapter: Dynamic HTML templates
Lecture: Template languages options

Login or purchase this course to watch this video and the rest of the course contents.
0:00 With Python, we have a choice of different template languages.
0:03 So what I'd like to do in this section is talk about three of the main
0:07 possible choices that you might choose for this dynamic HTML templating that we're gonna do
0:12 and see the trade offs, and then we have to pick one and go with
0:15 it for the course. So we're going to do that,
0:17 and I'll give you the motivation for doing so.
0:19 But let's go through three popular ones.
0:21 If you've ever done Flask, you've done Jinja.
0:24 So, Jinja is really the one templating language that is deeply supported by Flask.
0:29 There are many other frameworks that use Jinja as well. A lot of different,
0:33 maybe smaller web frameworks that are not quite as popular,
0:36 that also happen to leverage Jinja,
0:37 so Jinja very well may be the most popular,
0:40 most well known choice. Mako is another template language and looks quite similar to Jinja.
0:46 I think I actually like
0:48 Mako a little bit better, you'll see that there's a little bit less: open,
0:51 close, open, close all of these things
0:53 you have to keep writing; and it's, here's a template line and then you just write
0:58 some Python. That's pretty nice.
1:00 And then we're also going to talk about Chameleon.
1:02 Chameleon is unique because it doesn't leverage directly writing Python as much,
1:07 but it uses more of an attribute driven way of working with the HTML so you might
1:13 pass some date over. There might be an attribute that says:
1:16 if this condition is true, show or hide this element that has the attribute,
1:20 whereas Jinja and Mako would actually have an if statement directly in their HTML,
1:25 so there's drawbacks and benefits to each one of these as we will see.