Padding Parser
The Padding Parser allows you to add padding characters to strings to ensure they reach a specific length. You can specify the length, padding character, and padding direction.
Usage
To use the parser, insert the following syntax in your text:
{padding(length:padChar:direction):text}
- You can also reference this parser using the alias: pad
Examples
- Left padding (default):
- Input:
{pad(4):42} - Output:
0042
- Custom padding character:
- Input:
{pad(4:*):42} - Output:
**42
- Right padding:
- Input:
{pad(4:0:right):42} - Output:
4200
- Center padding:
- Input:
{pad(4:-:both):42} - Output:
-42-
Available Parameters
| Parameter | Description | Default | Example |
|---|---|---|---|
| length | Target length for the string (required) | - | 4 |
| padChar | Character used for padding | ”0” | * |
| direction | Padding direction: “left”, “right”, or “both" | "left” | right |
Notes:
- If the text is already equal to or longer than the specified length, it will be returned unchanged
- For “both” (center) padding, if the padding cannot be distributed evenly, the extra padding character will be added to the right side