mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-17 01:40:42 -07:00
Add some more docs
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
---
|
||||
title: escape
|
||||
---
|
||||
|
||||
Escapes a string by replacing characters with escape sequences (so that the string can be used in a URI).
|
||||
|
||||
| Code | Output |
|
||||
|-------------------------------------------------------:|:-------------------|
|
||||
| {% raw %}`{{ "Need tips? Ask a friend!" | escape }}`{% endraw %} | `"Need%20tips%3F%Ask%20a%20friend%21"` |
|
||||
| {% raw %}`{{ "Nope" | escape }}`{% endraw %} | `"Nope"` |
|
||||
|
||||
It doesn't modify strings that have nothing to escape.
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
---
|
||||
title: escape_once
|
||||
---
|
||||
|
||||
Escapes a string without affecting existing escaped entities.
|
||||
|
||||
| Code | Output |
|
||||
|-------------------------------------------------------:|:-------------------|
|
||||
| {% raw %}`{{ "1 < 2 & 3" | escape_once }}`{% endraw %} | `"1 < 2 & 3"` |
|
||||
| {% raw %}`{{ "<< Accept & Checkout" | escape_once }}`{% endraw %} | `"<< Accept & Checkout"` |
|
||||
| {% raw %}`{{ "Nope" | escape_once }}`{% endraw %} | `"Nope"` |
|
||||
|
||||
It doesn't modify strings that have nothing to escape.
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
---
|
||||
title: first
|
||||
---
|
||||
|
||||
Return the first element of an array.
|
||||
|
||||
| Code | Output |
|
||||
|-------------------------------------------------------:|:-------------------|
|
||||
| {% raw %}`{{ product.tags | first }}`{% endraw %} | `"sale"` |
|
||||
|
||||
In the sample above, assume that `product.tags` resolves to: `["sale", "mens", "womens", "awesome"]`.
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
---
|
||||
title: floor
|
||||
---
|
||||
|
||||
`floor` rounds the input down to the nearest whole number.
|
||||
|
||||
| Input | Output |
|
||||
|-------------------------------------------:|:-------|
|
||||
| {% raw %}`{{ 1.2 | floor }}` {% endraw %} | 1 |
|
||||
| {% raw %}`{{ 1.7 | floor }}` {% endraw %} | 1 |
|
||||
| {% raw %}`{{ 2.0 | floor }}` {% endraw %} | 2 |
|
||||
| {% raw %}`{{ "18.3" | floor }}`{% endraw %} | 18 |
|
||||
|
||||
It will attempt to cast any input to a number.
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
---
|
||||
title: join
|
||||
---
|
||||
|
||||
`join` joins the elements of an array, using the character you provide.
|
||||
|
||||
| Code | Output |
|
||||
|-------------------------------------------------------:|:-------------------|
|
||||
| {% raw %}`{{ product.tags | join: ', ' }}`{% endraw %} | `"sale, mens, womens, awesome` |
|
||||
|
||||
In the sample above, assume that `product.tags` resolves to: `["sale", "mens", "womens", "awesome"]`.
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
---
|
||||
title: last
|
||||
---
|
||||
|
||||
Return the last element of an array.
|
||||
|
||||
| Code | Output |
|
||||
|-------------------------------------------------------:|:-------------------|
|
||||
| {% raw %}`{{ product.tags | last }}`{% endraw %} | `"awesome"` |
|
||||
|
||||
In the sample above, assume that `product.tags` resolves to: `["sale", "mens", "womens", "awesome"]`.
|
||||
|
||||
Reference in New Issue
Block a user