Jinja Filters: basic filter

Jinja filter Section n n The filter section in Jinja2 allows you to apply one or more filters to an entire block of content, rather than just a single variable. This is a powerful and elegant way to perform transformations on a large section of your template, which helps keep your code clean and avoids…

Jinja Call: basic call block

Jinja call Block n n The **call block** in Jinja2 is a special construct that allows you to pass a segment of template code to a macro. This is extremely useful for creating reusable container-style macros that wrap content with a consistent structure, like a dialog box, a panel, or a card component. nn n…

Jinja Macros: introduction

Jinja Macros Introduction n n Macros in Jinja2 are powerful tools for creating reusable code snippets, much like **functions in regular programming languages**. They are a cornerstone of the “Don’t Repeat Yourself” (DRY) principle, allowing you to define a template element once and reuse it across your project, saving time and ensuring consistency. nn n…

Jinja Literal Expression: boolean

Jinja2 Literal Expression: Booleans n nnA boolean literal represents a value that is either true or false. These are fundamental for controlling program flow and logic in your templates. The values `true` and `false` are always lowercase. For consistency with Python and to avoid past confusion, you can also use True and False, but the…

Jinja Literal Expression: dict

Jinja Literal Expression: Dictionaries n nnA dictionary is a structure that combines unique keys and their corresponding values. In Jinja2, a dictionary literal is created with a set of curly braces containing comma-separated key-value pairs ({key: value}). Keys must be unique and always have exactly one value. While dictionaries are not as frequently used in…

Jinja Literal Expression: tuple

Jinja Literal Expression: Tuples n nnA tuple is a sequence of comma-separated values, enclosed in parentheses ((…)). The key difference between a tuple and a list is that a tuple is immutable, meaning its contents cannot be changed after it is created. Tuples are generally used to represent a fixed collection of related items, such…

Jinja Literal Expression: lists

Jinja Literal Expression: Lists n nnA list literal is a sequence of comma-separated values, enclosed in square brackets ([…]). Lists are useful for storing sequential data that you need to iterate over, such as a collection of items, user accounts, or navigation links. Lists are also mutable, meaning you can change their contents.nn nn How…

Jinja Literal Expression: integers

Jinja Literal Expression: Integers n nnAn integer literal is a whole number without a decimal point. Integers are a fundamental data type in Jinja2 used for counting, performing arithmetic, and controlling logic in your templates. For improved readability, the underscore character (_) can be used as a visual separator for large numbers, similar to how…