Skip to content

Commit

Permalink
README: Add a note on parseFloat and printf
Browse files Browse the repository at this point in the history
  • Loading branch information
ppai-plivo committed Jul 10, 2020
1 parent 6153694 commit 3f023e5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -1792,6 +1792,19 @@ Takes the given string and parses it as a base-10 float64:
{{ "1.2" | parseFloat }}
```

Note: The float64 value is rendered as per [Go's text/template][text-template]
package and has the same precision and format in output as when
`fmt.Fprint(w, value)` is called. For example, when the input string is `1.0`,
the rendered output is `1`. However, if you pipe it to another function, it is
passed as a floating point, so with the built-in printf you can format it as
you like, for example:

```liquid
{{ "1.0" | parseFloat | printf "%.1f" }}
```

This is rendered as `1.0`.

##### `parseInt`

Takes the given string and parses it as a base-10 int64:
Expand Down

0 comments on commit 3f023e5

Please sign in to comment.