$$pad
Pad a provided string with certain character(s) repeated until a certain width of output string
(Strings longer than width
will be returned as-is)
Usage​
{
"$$pad": /* input */,
"direction": /* LEFT / START / RIGHT / END */,
"width": /* integer */,
"pad_string": "0" /* string */
}
"$$pad(<direction>,<width>,[pad_string]):{input}"
note
Concrete values in the usage example are default values.
Returns​
string
Arguments​
Argument | Type | Values | Required / Default Value | Description |
---|---|---|---|---|
Primary | any | null | Value to pad | |
direction | enum | LEFT / START /RIGHT /END | Yes | On which side of the input to pad |
width | integer | Yes | What is the maximum length of the output string | |
pad_string | string | "0" | The character(s) to pad with |
Examples​
Input
Definition
Output
"text"
"$$pad(END,6):text"
"text00"
"text"
"$$pad(RIGHT,6,0):$"
"text00"
"text"
"$$pad(END,6,' '):$"
"text "
"text"
"$$pad(LEFT,6,' '):$"
" text"
"text"
"$$pad(LEFT,6,x):$"
"xxtext"
"text"
"$$pad(RIGHT,3,2):$"
"text"
"text"
"$$pad(START,6,xy):$"
"xytext"
"text"
"$$pad(START,9,xy):$"
"xyxyxtext"
"text"
"$$pad:$"
"text"
"text"
"$$pad(START):$"
"text"