From d9b2d500452dfda14bde612f296e237ebb2f90f9 Mon Sep 17 00:00:00 2001 From: Tetsuro Date: Sat, 25 Jul 2015 17:48:18 -0400 Subject: [PATCH] WIP: Adding missing filters --- _filters/round.md | 9 +++++++++ _filters/slice.md | 17 +++++++++++++++++ _filters/truncate.md | 7 +++++++ _filters/truncatewords.md | 7 +++++++ _filters/uniq.md | 7 +++++++ _filters/upcase.md | 8 ++++++++ 6 files changed, 55 insertions(+) diff --git a/_filters/round.md b/_filters/round.md index f449506..86c4301 100644 --- a/_filters/round.md +++ b/_filters/round.md @@ -1,3 +1,12 @@ --- title: round --- + +Rounds the output to the nearest integer or specified number of decimals. + +| Input | Output | +|:-------------------------------------------|:-------| +| {% raw %}`{{ 4.6 | round }}` {% endraw %} | 5 | +| {% raw %}`{{ 4.3 | round }}` {% endraw %} | 4 | +| {% raw %}`{{ 4.5612 | round: 2 }}` {% endraw %} | 4.56 | + diff --git a/_filters/slice.md b/_filters/slice.md index e2d3ddf..3fb7628 100644 --- a/_filters/slice.md +++ b/_filters/slice.md @@ -1,3 +1,20 @@ --- title: slice --- + +The slice filter returns a substring, starting at the specified index. An optional second parameter can be passed to specify the length of the substring. If no second parameter is given, a substring of one character will be returned. + + +| Input | Output | +|:------------------------------------------------|:-------| +| {% raw %}`{{ "hello" | slice: 0 }}`{% endraw %} | h | +| {% raw %}`{{ "hello" | slice: 1 }}`{% endraw %} | e | +| {% raw %}`{{ "hello" | slice: 1, 3 }}`{% endraw %} | ell | + + +If the passed index is negative, it is counted from the end of the string. + +| Input | Output | +|:------------------------------------------------|:-------| +| {% raw %}`{{ "hello" | slice: -3, 2 }}`{% endraw %} | ll | + diff --git a/_filters/truncate.md b/_filters/truncate.md index 29314aa..60b307e 100644 --- a/_filters/truncate.md +++ b/_filters/truncate.md @@ -1,3 +1,10 @@ --- title: truncate --- + + +

Truncates a string down to 'x' characters, where x is the number passed as a parameter. An ellipsis (...) is appended to the string and is included in the character count.

+ +| Input | Output | +|:-------------------------------------------|:-------| +| {% raw %}`{{ "The cat came back the very next day" | truncate: 10 }}`{% endraw %} | "The cat..." | diff --git a/_filters/truncatewords.md b/_filters/truncatewords.md index bc1aca3..4747838 100644 --- a/_filters/truncatewords.md +++ b/_filters/truncatewords.md @@ -1,3 +1,10 @@ --- title: truncatewords --- + + +

Truncates a string down to 'x' words, where x is the number passed as a parameter. An ellipsis (...) is appended to the truncated string.

+ +| Input | Output | +|:-------------------------------------------|:-------| +| {% raw %}`{{ "The cat came back the very next day" | truncatewords: 4 }}`{% endraw %} | The cat came back...| diff --git a/_filters/uniq.md b/_filters/uniq.md index 1730f1e..0f36115 100644 --- a/_filters/uniq.md +++ b/_filters/uniq.md @@ -1,3 +1,10 @@ --- title: uniq --- + + +

Removes any duplicate instances of an element in an array.

+ +| Input | Output | +|:-------------------------------------------|:-------| +| {% raw %}`{% assign fruits = "orange apple banana apple orange" %} {{ fruits | split: ' ' | uniq | join: ' ' }}`{% endraw %} | orange apple banana | diff --git a/_filters/upcase.md b/_filters/upcase.md index 62ee820..1b50d88 100644 --- a/_filters/upcase.md +++ b/_filters/upcase.md @@ -1,3 +1,11 @@ --- title: upcase --- + +

Converts a string into uppercase.

+ + +| Input | Output | +|:-------------------------------------------|:-------| +| {% raw %}`{{ 'loud noises' | upcase }}`{% endraw %} | LOUD NOISES | +