Skip to content

format (Function)

Substitute {} placeholders in a template with values. Inputs are coerced to strings, letting you mix strings, numbers, and booleans safely.

๐Ÿค– AI-Generated Content

This documentation was generated with AI assistance and is still being audited. Some, or potentially a lot, of this information may be inaccurate. Learn more.

Note

This provider is in pre-release and under active development. Features and APIs may change without notice and it is not intended for production infrastructure.

Example Usage

locals {
  format_message = provider::pyvider::format("User {} has {} roles.", ["admin", 3])
  # "User admin has 3 roles."
}

output "format_message" {
  value = local.format_message
}

Signature

format(template: string, values: list[any]) -> string

Parameters

  • template (string, required) โ€” String containing {} placeholders. Returns null when the template is null.
  • values (list[any], required) โ€” Positional values inserted into the template. A null list is treated as empty.

Returns

A formatted string or null when the template is null.

Notes

  • An error is raised if the number of values does not match the number of placeholders.