jinja2 Questions
3
I have jinja template file with variable names like x.y.z (like java package names). Then I'm using Python envtpl to generate actual config file from jinja template file using envtpl.process_file. ...
4
Solved
I have a small, test FastAPI web application that is serving a simple HTML page that requires a css style sheet located in the static folder. It is installed on a Linode server (Ubuntu 20.04 LTS), ...
7
Solved
Is it possible to access a OS environment variable directly from a Jinja2 template?
3
Solved
I want to use Sphinx's autosummary extension and templates to generate API docs recursively from docstrings. I want separate pages for each module, class, method, property and function. But it does...
Kessiah asked 3/1, 2018 at 8:57
2
Solved
Background:
This is an Ansible playbook using templates to CONSTRUCT a yaml file from a template. So basically I have a jinja2 template file with a line as such:
private_key: {{ myvar }}
Ansi...
2
So I found the "jinja: "true" option for launch.json and am trying to make jinja debugging work, unsuccessfully so far.
My launch.json is currently:
{
"version": "0.2...
Methaemoglobin asked 21/8, 2020 at 6:56
5
I'm adding language translation support to my project. The code is on Python and has jinja2 in the html files, and Javascript.
I'm trying to use Babel to do the translation, but it doesn't recogni...
Martinson asked 21/8, 2012 at 0:28
4
Solved
The variable in Python :
names = ["a", "b"]
What I write currently in Jinja2 template:
c({{ names | join(",") }})
What I get using the template above:
c(a, b)
However, what I really need i...
Ker asked 20/3, 2013 at 2:45
1
How do I convert a string to a datetime object inside of a jinja2 template?
I want to do something like the following, but strptime is not recognized.
{% set dtime=strptime(passedintime, '%H:%M:%S'...
Prestissimo asked 2/6, 2021 at 14:44
9
Solved
I am trying to get list of all variables and blocks in a template. I don't want to create my own parser to find variables. I tried using following snippet.
from jinja2 import Environment, PackageL...
Gocart asked 24/11, 2011 at 17:5
2
Solved
hello I want to set the value of an item in a list in jinja2, for that I'm trying
<code>
{% set arr=[0,0,0,0,0,0,0,0] %}
{% print arr %}
{% set arr[1] = 1 %}
{% print arr %}
</code>
...
5
How can I put comments inside Jinja2 argument list declaration ?
Everything I have tried gives an error:
jinja2.exceptions.TemplateSyntaxError: unexpected char u'#'
{{ Switch('var',
[('1', 'foo'...
3
Solved
In jinja, the variable loop.index holds the iteration number of the current running loop.
When I have nested loops, how can I get in the inner loop the current iteration of an outer loop?
Butterfish asked 14/10, 2009 at 15:59
7
Solved
Below is the jinja2 template that i wrote to use in ansible.
{% set port = 1234 %}
{% set server_ip = [] %}
{% for ip in host_ip %}
{% do server_ip.append({{ ip }}:{{ port }}) %}
{% endfor %}
{% s...
Monroe asked 2/4, 2018 at 22:5
2
Solved
A little question to jinja2 templating:
I want to create a reusable template to include and then overwrite blocks. Macros do not let me write junks of HTML easily as parameters do they? Say I want ...
5
I know we can set Jinja variable to js variable like this.
var x = {{ 'value' }}
but I am trying to do the reverse. i.e I am trying to set javascript value to jinja variable. I tried the followi...
Sherrillsherrington asked 13/4, 2017 at 4:56
4
Solved
I have this html snippet which needs to be used in lots of places in the jinja2 templates:
<div class="usedalot">{{ somevalue }}</div>
for example, in template1.html, template2.html....
4
Solved
I want to pass multiple variables from my Flask view to my Jinja template. Right now, I can only pass one. How do I pass multiple variable when rendering a template?
@app.route("/user/<user...
2
Solved
When map'ing a attribute in a list of nested variables, I am not able to retrieve its key.
I want to retrieve the key of "tls_cert_file" from followingemphasized text variables:
vault_config_list...
3
Solved
I am currently trying to loop over a subset of k8s_facts. My fact looks something like:
{
"resources": [
{
"metadata": {
"annotations": {
"com.foo.bar/name": "foo",
"com.foo.bar/foo-name": ...
2
Solved
I did't find it written explicitly in the docs.
Are the naming rules the same as with Python variables?
(eg: {{ a_variable'like_that' }} doesn't work for example)
5
Solved
I want to use Jinja2 and Django crispy forms together, but when I load crispy_forms_tags in my template and trying to render form with this template tag, I get an error:
Encountered unknown tag 'c...
Magnetic asked 18/8, 2014 at 13:49
2
Solved
I have a long Jinja2 template which has many nested if/for statements. It's very hard to read. I would like to indent the {% %} bits, to make it clearer.
However if I do that, the contents of those...
Concentric asked 10/9, 2019 at 6:0
2
Solved
I have a template(test.html) as follows:
{% extends 'base.html' %}
{% from "_formhelpers.html" import render_field %}
{% block content %}
<div class="container">
<div class="row">
...
4
Solved
I just write this code in a HTML page.
{% for i, val in enumerate(['a', 'b', 'c']) %}
<td>
{{ val }}
</td>
{% endfor %}
UndefinedError: 'enumerate' is undefined
So, Flask do not ...
1 Next >
© 2022 - 2025 — McMap. All rights reserved.