jinja2

Iterating through list of dictionaries within a dictionary – Jinja2 and Ansible

Iterating through list of dictionaries within a dictionary – Jinja2 and Ansible Question: I am trying to extract the "host" and "port" value from the following JSON output with Jinja2: "net_neighbors": { "Ethernet0/0": [ { "host": "Switch", "platform": "Linux Unix", "port": "Ethernet0/2" } ], "Ethernet0/1": [ { "host": "DAL-R", "platform": "Linux Unix", "port": "Ethernet0/1" } …

Total answers: 1

Problem with double {{ }} syntax (one inside second)

Problem with double {{ }} syntax (one inside second) Question: I just try to make dynamic path to a folder with photo depending on an object name which is variable. How should I do this ? <img src="{{url_for(‘/{{object.name}}’, filename=’photo.jpg’)}}"/> I think that before this variable i have to give a special sign … Can anybody …

Total answers: 1

build new variables in Jinja2 Loop and use it

build new variables in Jinja2 Loop and use it Question: I have a file containing a YAML document, with informations about vlans: #yaml_file.yaml – vlan: 123 name: DATEN-VLAN – vlan: 124 name: PRINTER-VLAN – vlan: 125 name: WLAN-VLAN Then I created a Jinja2Template to loop through the vlans: {% for vlan in vlans %} interface …

Total answers: 1

Python – jinja2 template picks up only the first record from the data

Python – jinja2 template picks up only the first record from the data Question: I would like to make the on-click feature with a circle coming up when clicking on the marker. So far I’ve developed the class which includes relevant elements as shown in the code below: df = pd.read_csv("survey.csv") class Circle(MacroElement): def __init__(self): …

Total answers: 1

How to Negate in this Jinja if condition?

How to Negate in this Jinja if condition? Question: I have this in template: {% if cell %}{% set cell = "b" %}{% endif %} What is contradiction of above conditional? This not works: {% if !cell %} Asked By: parmer_110 || Source Answers: You might use not word, consider following simple example import jinja2 template = jinja2.Template(‘cell {% if not cell …

Total answers: 1

Use python jinja to auto-increment Image id from SQL-Alchemy-DB served in html via flask

Use python jinja to auto-increment Image id from SQL-Alchemy-DB served in html via flask Question: I am trying to create a gallery.html which changes picture behaviour by image id e.g id="lightbox-1", id="lightbox-2", id="lightbox-3" and the gallery behaviour alters according to css, this works well using file paths as sample code highlight below: <div id="gallery"> <div><img …

Total answers: 1

Checking value is in a list of dictionary values in Jinja

Checking value is in a list of dictionary values in Jinja Question: I have a list of tables coming from a SQLite database: tbls_name = db_admin.execute( """SELECT name FROM sqlite_master WHERE type=’table’;""" ) And need to check if table_name is in the resulting list of dictionaries. In Python, I would do: if table_name in [d[‘name’] …

Total answers: 1

Can’t loop value in html table

Can’t loop value in html table Question: I’m building a function which can let admin to delete account in that page. I have several accounts in admin page but all the delete buttons are holding a value from first account in that page instead of other account. <form action="/admin" method="post"> <table class="table"> <thead class="table-dark"> <tr> …

Total answers: 2