Jinja Templating (Overview)
Templates are an essential ingredient in full-stack web development. With Jinja, you can build rich templates that power the front end of your Python web applications.
Jinja is a text templating language. It allows you to process a block of text, insert values from a context dictionary, control how the text flows using conditionals and loops, modify inserted data with filters, and compose different templates together using inheritance and inclusion.
In this video course, you’ll learn 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
This video course is for you if you want to learn more about the Jinja template language or if you’re getting started with Flask.
00:00 Welcome to Jinja Templating. My name is Christopher, and I will be your guide. This course is all about the Jinja2 library with a splash of its use inside of Flask. You’ll learn about Jinja2 templates, how they substitute values, what template tags are, how to modify data with filters, writing inclusion macros, and just enough Flask to play with Jinja2 templates and HTML.
00:31 Code in this course was tested using Python 3.11, Jinja2 3.1, and Flask 2.3. Jinja2 is a template-processing tool kit which allows you to create text-based templates with content value placeholders, which are then rendered into a result. Within a template, you can substitute variables, perform control flow like conditionals and looping, and compose and combine templates so you can organize your templates like you organized your code. Flask is a web application framework, and Jinja2 integrates with it quite well where the templating is commonly used to manage your HTML output.
Become a Member to join the conversation.