You are viewing the Resources for the older version of JourneyApps (V3). JourneyApps V4 is the new default for all new apps since July 1, 2016.

Format Strings

Format strings is a simple format to used to generate string representations of objects, typically used in lists.

Simple examples:

  • {name} {surname} 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 are evaluated on the object. This includes attribute 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 attribute 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:

string

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

int

{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.

datetime

{datetime:%G} gives an English representation of (absolute) time difference, for example "0 minutes, 1 hour, 3 weeks". The minimum accuracy is a minute.

Please Note:

Formatting of a datetime using {datetime:%G} is currently only supported on JourneyApps on Android, not on iOS or Chrome yet.

date

{date:%G} gives an English representation of (absolute) date difference, for example "3 months". The minimum accuracy is a day.

Please Note:

Formatting of a date using {date:%G} is currently only supported on JourneyApps on Android, not on iOS or Chrome yet.

decimal

{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.