Skip to content

Commit 7a11e87

Browse files
committed
Add example!
1 parent 15b59fd commit 7a11e87

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎website/docs/language/functions/format.mdx‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,23 @@ Hello, Valentina!
3434
Hello, Valentina!
3535
```
3636

37+
The formatting verb `%#v` accepts a value of any type and presents it using JSON encoding, similar to jsonencode. This can be useful for describing the values given to a module in [custom condition check](/language/expressions/custom-conditions#error-messages) error messages.
38+
39+
```
40+
> format("%#v", "hello")
41+
"\"hello\""
42+
> format("%#v", true)
43+
"true"
44+
> format("%#v", 1)
45+
"1"
46+
> format("%#v", {a = 1})
47+
"{\"a\":1}"
48+
> format("%#v", [true])
49+
"[true]"
50+
> format("%#v", null)
51+
"null"
52+
```
53+
3754
The `format` function is most useful when you use more complex format specifications.
3855

3956
## Specification Syntax

0 commit comments

Comments
 (0)