From Pittsburgh Streets
The {{leftpad}} template pads a given string on the left with a specified character to make it a specified width.


Parameter Description
width The desired width of the padded string. The value of width is evaluated inside an #ifexpr, so it can be a mathematical expression. Note that {{leftpad}} uses {{repeat}}, which has a maximum repetition of 15, so an error will be produced if more than 15 padding characters are needed.
pad The padding character. This is assumed to be a single character (this assumption is necessary to support things like pad={{space}}). If pad is not specified, {{space}} will be used, but this is kinda pointless because multiple consecutive spaces are treated as a single space in HTML.

Usage examples

  • {{leftpad|width=8|pad=0|123}} → 00000123
  • {{leftpad|width=2+3|pad=.|abc}} → ..abc
  • {{leftpad|width=3|pad=0|12345}} → 12345
  • {{leftpad|width=10|abc}} → abc
  • {{leftpad|pad=X|abc}} → abc
  • {{leftpad|abc}} → abc