Say I have
{% for key,value in adict %} {{key}}:{{value}} {% endfor %}
How to ensure that all keys are filled so that the output
something: 1 someotherthing: 3 thelastthing: 2
edit: This is not the webpage I'm working on, I just get the string output for printing. A.
{{ key.rjust(20) }}:{{value}} did the trick
{{ key.rjust(20) }}:{{value}}
I did not know that you can just call python string commands from a window. If someone has a more "jinja" solution using pipes, I will give an answer to this.
Use the built-in Jinja2 filter called format . For instance:
Left-aligned line of width 20:
{{ "%-20s"|format(variable) }}
Right aligned row of width 20:
{{ "%20s"|format(variable) }}
Your case:
{{ "%20s:%s"|format(key, value) }}
Source: https://habr.com/ru/post/948474/More articles:PHP code to execute multiple queries with a single mysql_query () call - phpchanging phpmyadmin's default url - linuxhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/948471/how-to-avoid-double-submissions-to-amazon-ses&usg=ALkJrhjPXoRPe0mv79JdI1MHR1pyfdVm4AFilling state and city drop-down lists by country and state with jQuery - jsonlaunch python-daemon as an irreconcilable user and save group memberships - pythonSending mail using Flask-Mail - flaskhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/948476/pass-arguments-to-parent-controller-method-from-directive&usg=ALkJrhgkygiKuqldtRXdeOj0o-7cYv953AHow to develop push notifications for android without using Google cloud messaging? - androidPublic Folder Options for vmware on ESXi Server - folderMVC 4. ModelState.IsValid always returns true - c #All Articles