@@ -854,31 +854,69 @@ argument.
854854
855855## $(padding)
856856
857- | * Syntax:* | $(padding \< macro\> \< width\> \< prepended -character-or-string\> ) |
857+ | * Syntax:* | $(padding \< macro\> \< width\> [ \< padding -character-or-string\> ] ) |
858858
859859* Description:* This template function returns the value of its first
860- parameter (a string or macro), prepended with a string. This string is
861- \< width\> long, and repeats the character or string set in the third
862- parameter. If you use a single character, it is added \< width\> times.
863- If you use a string, it is repeated until its length reaches \< width\> .
864- The default padding character is \' \' (space). For example:
860+ parameter (a string or macro), padded to the specified width. From version 4.12 of
861+ {{ site.product.short_name }}, the padding direction depends on the sign of the \< width\> parameter:
865862
866- ### Example: Using the padding template function
863+ - ** Positive width** : Left-padding. The padding is added before (to the left of) the string.
864+ - ** Negative width** : Right-padding. The padding is added after (to the right of) the string.
867865
868- If the value of the ${MESSAGE} macro is mymessage, then the output of
869- the padding() template function is the following:
866+ The absolute value of \< width\> determines the total length of the output. If the
867+ input string is longer than the specified width, it is returned unchanged (not truncated).
868+
869+ The optional third parameter specifies the padding character or string. If you use a
870+ single character, it is repeated to fill the padding. If you use a string, it is
871+ repeated until the padding reaches the required length. The default padding character
872+ is ` ` (space).
873+
874+ ** NOTE:** The width parameter cannot be zero.
875+ {: .notice--info}
876+
877+ ### padding usage examples
878+
879+ If the value of the ${MESSAGE} macro is mymessage:
880+
881+ ** Left-padding with spaces (default):**
882+
883+ ``` config
884+ $(padding ${MESSAGE} 15)
885+ ```
886+
887+ Output: ` mymessage ` (6 spaces + mymessage = 15 characters total)
888+
889+ ** Left-padding with a character:**
870890
871891``` config
872- $(padding ${MESSAGE} 10 X)
892+ $(padding ${MESSAGE} 15 X)
873893```
874894
875- Output: XXXXXXXXXXmymessage
895+ Output: ` XXXXXXmymessage ` (6 X's + mymessage = 15 characters total)
896+
897+ ** Left-padding with a string:**
898+
899+ ``` config
900+ $(padding ${MESSAGE} 16 foo)
901+ ```
902+
903+ Output: ` foofoofmymessage ` (repeats "foo" until reaching 16 characters total)
904+
905+ ** Right-padding with spaces:**
906+
907+ ``` config
908+ $(padding ${MESSAGE} -15)
909+ ```
910+
911+ Output: ` mymessage ` (mymessage + 6 spaces = 15 characters total)
912+
913+ ** Right-padding with a character:**
876914
877915``` config
878- $(padding ${MESSAGE} 10 foo )
916+ $(padding ${MESSAGE} -15 X )
879917```
880918
881- Output: foofoofoofmymessage
919+ Output: ` mymessageXXXXXX ` (mymessage + 6 X's = 15 characters total)
882920
883921## $(python)
884922
0 commit comments