jinja2 Questions

4

Solved

Say I have a template layout saved in template.html. This template includes a banner, side navigation, content container, and footer. Can I use flask to break up these page elements in such a way t...
Riehl asked 13/3, 2012 at 5:55

3

Solved

I have a page with the following Code Structure: Python Code: from flask import Flask,render_template app=Flask(__name__) @app.route('/') def home(): return render_template("first.html") @app...
Darla asked 2/6, 2020 at 11:44

5

Solved

How can I break out of a for loop in jinja2? my code is like this: <a href="#"> {% for page in pages if page.tags['foo'] == bar %} {{page.title}} {% break %} {% endfor %} </a> I hav...
Vambrace asked 3/3, 2014 at 15:10

2

Solved

We're using Airflow v2.2.3 on Kubernetes (KubernetesExecutor), our environment requires a DAG pre-customer, and each customer can be in a different timezone. Each DAG should be scheduled in its own...
Psychopharmacology asked 31/1, 2022 at 10:52

2

A normal jinja2 include looks like {% include 'directory/filename.html' %} but I am looking to do something like `{% include 'dropins/*.html' % where obviously the order would be alphabetically. I...
Wachtel asked 25/8, 2013 at 8:7

6

Solved

A bottle project of mine uses Jinja2. PyCharm does not automatically recognize it and shows such lines as errors. Is there a way to make Jinja2 work?
Gaitan asked 1/4, 2013 at 19:44

3

I have URLs stored in a Django model that I would like to display on a template, but I would only like to display the domain like this: original_url: https://wikipedia.org/wiki/List_of_chemical_...
Mirnamirror asked 29/12, 2014 at 21:31

9

Solved

I am getting the error ImportError: cannot import name 'escape' from 'jinja2' When trying to run code using the following requirements.txt: chart_studio==1.1.0 dash==2.1.0 dash_bootstrap_componen...
Hallelujah asked 2/4, 2022 at 13:56

2

Solved

I'm trying to disable Jinja2's template cache. I've done some looking around, and I've found that there's a cache_size parameter for jinja's environment. I'm using the following: app.jinja_env = ...
Firenze asked 1/6, 2016 at 17:20

3

Solved

I have made some small macro that I am using to display text line and label for it: {% macro input(name, text, help_text, value="", input_type) -%} <label for="id_{{name}}">{{text}}<span...
Selfservice asked 28/8, 2012 at 16:49

3

Solved

I migrated an application in Flask served by waitress to FastAPI served by uvicorn, but I can't force the links (generated by url_for inside the index.html template) to use HTTPS instead of HTTP. W...
Tema asked 29/12, 2021 at 15:53

6

Solved

How do I persuade Jinja2 to not print "None" when the value is None? I have a number of entries in a dictionary and I would like to output everything in a single loop instead of having special cas...
Cupellation asked 21/6, 2012 at 20:57

2

Solved

There is a urlencode filter in Jinja, which can be used with {{ url | urlencode }}, but I'm looking for a "plus" version that replaces spaces with + instead of %20, like urllib.quote_plus(). Is the...
Plumcot asked 31/10, 2015 at 10:13

4

Solved

How can I sort a dict like my_dict = { 'abc': {'name': 'B', 'is_sth': True}, 'xyz': {'name': 'A', 'is_sth': True} } by name in Jinja? I've tried {% for id, data in my_dict|dictsort(by='value'...
Scandal asked 21/4, 2017 at 11:45

5

Solved

I have a simple form like this: class RecordForm(Form): notes = TextAreaField('Notes') I record the data in three paragraphs like this: para1 para2 para3 In the template I would like to s...
Hedrick asked 6/9, 2013 at 17:0

7

Solved

I use VS code since a while with some Extensions. All is perfect expect when I use Flask. Prettier put all flask code glued together, and intellisence is not working with flask code: {% extends "...
Bohol asked 11/2, 2020 at 18:53

4

I have trouble to find basic filters for a list: 'any' (return true if any value in the list can be casted to true), 'all' (return true only of all values in the list can be casted to true). I can...
Jeb asked 2/4, 2019 at 9:16

6

Solved

I was a little bit surprised to discover that his piece of code fails with an IOError exception instead of defaulting to omitting the value. #!/usr/bin/env ansible-playbook -i localhost, --- - host...
Lens asked 4/4, 2017 at 15:58

7

Solved

I just want to loop through an existing list and make a comma delimited string out of it. Something like this: my_string = 'stuff, stuff, stuff, stuff' I already know about loop.last, I just need ...
Waxplant asked 14/1, 2010 at 0:41

4

Solved

I have some variables in a jinja2 template which are strings seperated by a ';'. I need to use these strings separately in the code. i.e. the variable is variable1 = "green;blue" {% list1 = {{ va...
Hindmost asked 28/5, 2015 at 19:25

3

Solved

The basics of what I am trying to do is to use the 'random' filter to choose a random item from my list but then I want to use that randomly chosen item in multiple locations. How do I set the res...
Epps asked 30/11, 2011 at 16:51

9

Solved

I need to programatically distinguish between Jinja template files, other template files (such as ERB), and template-less plain text files. According to Jinja documentation: A Jinja template do...
Exurbanite asked 12/4, 2015 at 15:8

8

Solved

How do i pass jinja2 data into javascript. I have a Flask REST url as /logs/<test_case_name> I am trying use .getJSON() to query the above URL and hence would want to pass the jinja2 data wh...
Houser asked 7/2, 2014 at 11:2

3

Solved

I added a facebook button to my page by copying/pasting the code they supply on their website. It looks like this: "http://www.facebook.com/dialog/feed?app_id={{fbapp_id}}&link={{link_url}}...
Graphy asked 6/8, 2013 at 1:35

3

I'm running Ansible and I try to make this task work. I have defined the default of the variable "docker_registries" to be an empty list: docker_registries: [] I noticed that I will get error when ...
Anatola asked 17/3, 2020 at 15:41

© 2022 - 2025 — McMap. All rights reserved.