I would like to achieve something similar to this (https://pyformat.info/#string_pad_align) in Jinja2.
In python if I want a string to always be a certain length I would do something like this:
'{:>10}'.format('test')
How can I do this in Jinja2?
From jinja2 documentation
In most cases it should be more convenient and efficient to use the % operator or str.format().
So you can always write
{{ "{:>10}".format("test") }}
so as to keep the modern format string syntax, which is usually feature-richer than the printf-style formatting from the other answer.
I found a solution! You can use the builtin filter for Jinja like so
{{ "%-10s" | format("test",) }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With