text
text, type
The text type stores Unicode text values up to 256 characters.
Example
t = "Hello World!"
show scalar "Text value" with t
This outputs the following scalar:
| Label | Value |
|---|---|
| Text value | Hello World! |
text, function
def const pure text(a: _typ): text
Returns the canonical text representation of a.
Example
show summary "Text conversions" with
text(true) as "Boolean"
text(123.45) as "Number"
text(date(2020, 8, 27)) as "Date"
text("Hello World!") as "Text"
This outputs the following list:
| Label | Value |
|---|---|
| Boolean | true |
| Number | 123.45 |
| Date | 2020-08-27 |
| Text | Hello World! |
Remarks
text() is used implicitly when interpolating values or when tiles need a text
representation.
Text interpolation
Text literals support interpolation using \{}.
a = 42
b = "bar"
c = date(2022, 2, 17)
x = "\{a} foo \{b} -- \{c}"
y = "\{c:MM/dd/yyyy}"
show summary "Interpolation" with
x as "Default"
y as "Formatted"
This outputs the following list:
| Label | Value |
|---|---|
| Default | 42 foo bar – 2022-02-17 |
| Formatted | 02/17/2022 |
Date format tokens
d: day of the month from 1 to 31dd: day of the month, zero-paddedddd: abbreviated day name (Mon, Tue, …)dddd: full day name (Monday, …)M: month number from 1 to 12MM: month number, zero-paddedMMM: abbreviated month name (Jan, Feb, …)MMMM: full month name (January, …)yy: two-digit yearyyyy: four-digit year