Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Jinja Templating (Summary)

Jinja is a feature-rich templating engine packaged with the Flask web framework. But you can also use Jinja independently of Flask to create templates that you can programmatically fill with content.

In this video course, you learned how to:

  • Install the Jinja template engine
  • Create your first Jinja template
  • Render a Jinja template in Flask
  • Use for loops and conditional statements with Jinja
  • Nest Jinja templates
  • Modify variables in Jinja with filters
  • Use macros to add functionality to your front end

With this knowledge, you’re ready to render HTML content from your favorite web framework. How do you use Jinja templating in your projects? Share your ideas in the discussion above!

For further investigation, check out:

Download

Sample Code (.zip)

12.3 KB
Download

Course Slides (.pdf)

941.4 KB

00:00 In the previous lesson, you took a dip with the fish-men swim team to learn Jinja2 macros. In this lesson, I’ll summarize the course and point you where you can learn some more.

00:12 Jinja2 is a templating kit that allows you to create text templates from strings or files. Inside a template, names surrounded in mustache braces get rendered as their corresponding value in the rendering context. In addition to rendering values, Jinja2 provides tags for control flow, including conditionals, loops, and assignment.

00:37 The filter feature allows you to modify the content of a value before it gets rendered, and you can start organizing your HTML like you organize your code, by taking advantage of inheritance and inclusion to compose templates together.

00:52 A common use of Jinja2 is to render HTML from the Flask web application framework, and the two projects work well together.

01:02 If you want to learn more about other tags or filters, take a look at the Jinja2 documentation. If you’d like to learn more about Flask, this tutorial shows you how to take an existing Python script and adapt it for the Web. If that data class thing piqued your interest, then this tutorial can show you some more. And finally, if you want to go deep on web development, this learning path has multiple articles and courses that introduce you to the world of Django. That’s it for me.

01:34 I hope you enjoyed the course. Thanks for your attention. I guess the only reasonable way to end this after all that Buffy stuff would be saying grrr argh.

Become a Member to join the conversation.