jinja2

Getting svg stored in a variable in jinja2

喜欢而已 提交于 2020-08-19 08:07:23
问题 I'm trying to get an alphanumeric-encoded barcode using the viivakoodi library. I got the barcode which I needed but I'm not able to display it in my HTML page using Jinja2. Here's my code: import barcode from StringIO import StringIO encoding_std = barcode.get_barcode_class('code128') ean = encoding_std('Test123') fp = StringIO() ean.write(fp) encoded_output = fp.getvalue() fp.close() I'm currently storing the barcode as SVG and I'm not able to display that in the HTML page. Using {{ encoded

Getting svg stored in a variable in jinja2

流过昼夜 提交于 2020-08-19 08:07:12
问题 I'm trying to get an alphanumeric-encoded barcode using the viivakoodi library. I got the barcode which I needed but I'm not able to display it in my HTML page using Jinja2. Here's my code: import barcode from StringIO import StringIO encoding_std = barcode.get_barcode_class('code128') ean = encoding_std('Test123') fp = StringIO() ean.write(fp) encoded_output = fp.getvalue() fp.close() I'm currently storing the barcode as SVG and I'm not able to display that in the HTML page. Using {{ encoded

jinja2 nested variables

谁说胖子不能爱 提交于 2020-08-17 19:38:07
问题 I am currently learning jinja2 and i am unsure on how to address variables the correct way: Here are my variables in yaml: --- hosts: app201.acme.com: {eth0: {ip: 46.0.0.1, netmask: 255.255.255.255}} graphite.acme.com: {eth0: {ip: 46.0.0.2, netmask: 255.255.255.255}, eth0.1: {ip: 10.2.90.1, netmask: 255.255.255.255}} and here the jinja2 template: {{ fqdn }} {% for interface in hosts[fqdn] %} {{ interface }} {{ hosts[fqdn].interface.ip }} << doesn't work {{ hosts[fqdn].{{ interface }}.ip }} <<

jinja2 nested variables

六眼飞鱼酱① 提交于 2020-08-17 19:37:46
问题 I am currently learning jinja2 and i am unsure on how to address variables the correct way: Here are my variables in yaml: --- hosts: app201.acme.com: {eth0: {ip: 46.0.0.1, netmask: 255.255.255.255}} graphite.acme.com: {eth0: {ip: 46.0.0.2, netmask: 255.255.255.255}, eth0.1: {ip: 10.2.90.1, netmask: 255.255.255.255}} and here the jinja2 template: {{ fqdn }} {% for interface in hosts[fqdn] %} {{ interface }} {{ hosts[fqdn].interface.ip }} << doesn't work {{ hosts[fqdn].{{ interface }}.ip }} <<

jinja2 nested for loops two lists

|▌冷眼眸甩不掉的悲伤 提交于 2020-08-09 18:41:50
问题 I have the following code that is not rendering the way I would like on the html front end. {% for image in images %} {% for title in titles %} <div class="card" style="width: 18rem;"> <img src="{{image}}" class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">{{title}}</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> <a href="#" class="btn btn-primary">Go somewhere</a> </div> {% endfor %} {%