XML Format Strings
Format strings are a simple way to generate string representations of objects, typically used in lists.
Simple examples:
  • {name} {last_name} on a person object could generate "Peter Parker".
  • {make} {model} [{serial_number}] on an asset object could generate Samsung P1000 [1234567890].
Anything between curly braces is evaluated on the object. This includes field access, as well as relationship lookups. For example, assuming an asset has a relationship category, we could have {asset.category.name}.

Format specifiers

We can specify how values should be formatted by using a colon after the field name. The possible format specifiers depend on the type of value we're formatting.
The following format specifiers are currently supported for the various types:

text

{value:n} pads value on the right with spaces until it is n characters long. Has no effect if value is longer than n.

integer

{value:n} pads the value on the left with spaces until it is n characters long. Has no effect if value is longer than n.
{value:0n} pads the value on the left with zeros until it is n characters long. Has no effect if value is longer than n.

number

{value:.Xf} displays a decimal value with exactly X digits. For example, R {value:.2f} could be used to format Rand values.

Escaping

Curly braces are escaped by using double curly braces. For example, {{some text}} generates "{some text}".

Credits

The format is loosely based on PEP 3101.
Copy link
On this page
Format specifiers
Escaping
Credits