on-internet
← Community

jinja2 right align a float : formatting issue

Stack Overflow ·

i'm trying to align some floats, it works great if I use 'X' character as the fill parameter in the formatting doc : <ul> {% for race in rrr[1] %} <li><i class="fa fa-road"></i> {{ '{:X>5.1f}'.format(race.distance_number) }}km <i class="fa fa-area-chart"></i>{{ '{:.0f}'.format(race.elevation_number) if race.elevation_number is not none else '' }} </li> {% endfor %} </ul> If I use a X it aligns things well with {{'{:X>5.1f}'.format(race.distance_number) }} But if I use a space {{ '{: >5.1f}'.format(race.distance_number) }} which ultimately is what I want, it's not aligned anymore is there any w

Comments

Sign in or sign up to comment and upvote.

No comments yet.