mirror of
https://github.com/kemko/liquid.git
synced 2026-01-08 19:25:40 +03:00
Merge pull request #742 from Shopify/code-labels-for-abs
Add code labels for abs filter
This commit is contained in:
@@ -4,34 +4,40 @@ title: abs
|
||||
|
||||
Returns the absolute value of a number.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ -17 | abs }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
17
|
||||
```
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 4 | abs }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
4
|
||||
```
|
||||
|
||||
`abs` will also work on a string if the string only contains a number.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "-19.86" | abs }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
19.86
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user