format(format, args...) produces a string by substituting values into a format template. It follows the same conventions as printf in most languages.
Signature
Format verbs
| Verb | Description |
|---|---|
%s | String |
%q | JSON-quoted string |
%d | Decimal integer |
%f | Floating-point number |
%g | Compact floating-point (removes trailing zeros) |
%G | Compact floating-point (uppercase exponent) |
%e | Scientific notation |
%E | Scientific notation (uppercase) |
%x | Hexadecimal (lowercase) |
%X | Hexadecimal (uppercase) |
%b | Binary |
%o | Octal |
%t | Boolean (true or false) |
%v | Any value in a natural format |
%% | Literal % |
Example
Build a Docker image tag with zero-padded build numbers:build_number = 7, computed.image_tag becomes api-build-0007.
Notes
formatis most useful when you need padding, alignment, or number formatting. For simple concatenation, string interpolation (${}) is more readable.- An incorrect number of arguments or incompatible types produce an error at evaluation time.