Top "Jinja2" questions

Jinja2 is a fast template engine for Python.

Set variable in jinja

I would like to know how can I set a variable with another variable in jinja. I will explain, I …

python templates variables variable-assignment jinja2
Get lengths of a list in a jinja2 template

How do I get the number of elements in a list in jinja2 template? For example, in Python: print(template.…

python jinja2
Jinja2 template not rendering if-elif-else statement properly

I am trying to set the text color using css in a jinja2 template. In the following code I want …

python css if-statement jinja2
In Jinja2, how do you test if a variable is undefined?

Converting from Django, I'm used to doing something like this: {% if not var1 %} {% endif %} and having it work if I …

jinja2
Jinja2 template variable if None Object set a default value

How to make a variable in jijna2 default to "" if object is None instead of doing something like this? {% if …

jinja2
How to iterate through a list of dictionaries in Jinja template?

I tried: list1 = [{"username": "abhi", "pass": 2087}] return render_template("file_output.html", list1=list1) In the template: <table border=2&…

python dictionary flask iteration jinja2
How can I pass data from Flask to JavaScript in a template?

My app makes a call to an API that returns a dictionary. I want to pass information from this dict …

javascript python flask jinja2
How do I format a date in Jinja2?

Using Jinja2, how do I format a date field? I know in Python I can simply do this: print(car.…

python jinja2
How to output loop.counter in python jinja template?

I want to be able to output the current loop iteration to my template. According to the docs: http://wsgiarea.…

python jinja2
Link to Flask static files with url_for

How do you use url_for in Flask to reference a file in a folder? For example, I have some …

python flask jinja2