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