Liquex.Filter behaviour (liquex v0.14.0)

Copy Markdown View Source

Contains all the basic filters for Liquid

Summary

Functions

Returns the absolute value of value.

Appends text to the end of value

Sets a minimum value

Sets a maximum value

Decodes a base 64 string.

Encodes a string into base 64.

Decodes a URL-safe base 64 string.

Encodes a string into URL-safe base 64.

Capitalizes a string

Rounds value up to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.

Removes any nil values from an array.

Removes any items in the array whose property is nil.

Concatenates (joins together) multiple arrays. The resulting array contains all the items

Converts value timestamp into another date format.

Allows you to specify a fallback in case a value doesn’t exist. default will show its value if the left side is nil, false, or empty.

Divides a number by another number.

Makes each character in a string lowercase. It has no effect on strings which are already all lowercase.

Escapes a string by replacing characters with escape sequences (so that the string can be used in a URL, for example). It doesn’t change strings that don’t have anything to escape.

Escapes a string by replacing characters with escape sequences (so that the string can be used in a URL, for example). It doesn’t change strings that don’t have anything to escape.

Returns the first item in an array whose property is truthy. Returns nil if no item matches or the array is empty.

Returns the index of the first item in an array whose property is truthy or matches target_value. Returns nil if no item matches or the array is empty.

Returns the first item of an array.

Rounds the input down to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.

Returns true if any item in the array has the given property truthy or matching target_value, otherwise false. Returns false for empty arrays.

Combines the items in values into a single string using joiner as a separator.

Returns the last item of arr.

Removes all whitespace (tabs, spaces, and newlines) from the left side of a string. It does not affect spaces between words.

Creates an array (arr) of values by extracting the values of a named property from another object (key).

Subtracts a number from another number.

Returns the remainder of a division operation.

Replaces every newline ( ) in a string with an HTML line break (<br />).

Adds a number to another number.

Adds the specified string to the beginning of another string.

Returns the items of an array whose property is falsy, or whose property is not equal to target_value when given.

Removes every occurrence of the specified substring from a string.

Removes every occurrence of the specified substring from a string.

Removes only the last occurrence of the specified substring from a string.

Replaces every occurrence of the first argument in a string with the second argument.

Replaces only the first occurrence of the first argument in a string with the second argument.

Replaces only the last occurrence of the first argument in a string with the second argument. Returns the input unchanged if no occurrence is found.

Reverses the order of the items in an array. reverse cannot reverse a string.

Rounds a number to the nearest integer or, if a number is passed as an argument, to that number of decimal places.

Removes all whitespace (tabs, spaces, and newlines) from the right side of a string. It does not affect spaces between words.

Returns the number of characters in a string or the number of items in an array.

Returns a substring of 1 character beginning at the index specified by the first argument. An optional second argument specifies the length of the substring to be returned.

Sorts items in an array in case-sensitive order.

Sorts items in an array in case-insensitive order.

Divides a string into an array using the argument as a separator. split is commonly used to convert comma-separated items from a string to an array.

Removes all whitespace (tabs, spaces, and newlines) from both the left and right side of a string. It does not affect spaces between words.

Removes any HTML tags from a string. The contents of <script>, <style>, and HTML comments are stripped along with the tags themselves, matching the Liquid gem's strip_html behavior.

Removes any newline characters (line breaks) from a string.

Returns the sum of the items in an array. Items are coerced to numbers; with a property argument, the named property of each item is summed instead.

Multiplies a number by another number.

Shortens a string down to the number of characters passed as an argument. If the specified number of characters is less than the length of the string, an ellipsis (…) is appended to the string and is included in the character count.

Shortens a string down to the number of characters passed as an argument. If the specified number of characters is less than the length of the string, an ellipsis (…) is appended to the string and is included in the character count.

Removes any duplicate elements in an array.

Removes items from an array that share a value at the given property.

Makes each character in a string uppercase. It has no effect on strings which are already all uppercase.

Decodes a string that has been encoded as a URL or by url_encode/2.

Decodes a string that has been encoded as a URL or by url_encode/2.

Creates an array including only the objects with a given truthy property value

Creates an array including only the objects with a given property value, or any truthy value by default.

Types

filter_t()

@type filter_t() :: {:filter, [...]}

Callbacks

apply(any, filter_t, map)

@callback apply(any(), filter_t(), map()) :: any()

Functions

abs(value, _)

@spec abs(String.t() | number() | Decimal.t() | nil, any()) :: number() | Decimal.t()

Returns the absolute value of value.

Examples

iex> Liquex.Filter.abs(-1, %{})
1

iex> Liquex.Filter.abs(1, %{})
1

iex> Liquex.Filter.abs("-1.1", %{})
1.1

append(value, text, _)

@spec append(String.t(), String.t(), map()) :: String.t()

Appends text to the end of value

Examples

iex> Liquex.Filter.append("myfile", ".html", %{})
"myfile.html"

apply(mod \\ __MODULE__, value, arg, context)

at_least(value, max, _)

@spec at_least(number() | binary(), number() | binary(), map()) ::
  number() | Decimal.t()

Sets a minimum value

Examples

iex> Liquex.Filter.at_least(3, 5, %{})
5

iex> Liquex.Filter.at_least(5, 3, %{})
5

iex> Liquex.Filter.at_least("5", "3", %{})
5

at_most(value, max, _)

@spec at_most(number(), number(), map()) :: number() | Decimal.t()

Sets a maximum value

Examples

iex> Liquex.Filter.at_most(4, 5, %{})
4

iex> Liquex.Filter.at_most(4, 3, %{})
3

iex> Liquex.Filter.at_most("4", "3", %{})
3

base64_decode(value, _)

@spec base64_decode(String.t() | nil, map()) :: String.t()

Decodes a base 64 string.

Examples

iex> Liquex.Filter.base64_decode("X2hlbGxvXw==", %{})
"_hello_"

base64_encode(value, _)

@spec base64_encode(String.t() | nil, map()) :: String.t()

Encodes a string into base 64.

Examples

iex> Liquex.Filter.base64_encode("_hello_", %{})
"X2hlbGxvXw=="

base64_url_safe_decode(value, _)

@spec base64_url_safe_decode(String.t() | nil, map()) :: String.t()

Decodes a URL-safe base 64 string.

Examples

iex> Liquex.Filter.base64_url_safe_decode("X2hlbGxvIHdvcmxkPysv", %{})
"_hello world?+/"

base64_url_safe_encode(value, _)

@spec base64_url_safe_encode(String.t() | nil, map()) :: String.t()

Encodes a string into URL-safe base 64.

Examples

iex> Liquex.Filter.base64_url_safe_encode("_hello world?+/", %{})
"X2hlbGxvIHdvcmxkPysv"

capitalize(value, _)

@spec capitalize(String.t(), map()) :: String.t()

Capitalizes a string

Examples

iex> Liquex.Filter.capitalize("title", %{})
"Title"

iex> Liquex.Filter.capitalize("my great title", %{})
"My great title"

ceil(value, ctx)

@spec ceil(number() | String.t() | nil, map()) :: number()

Rounds value up to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.

Examples

iex> Liquex.Filter.ceil(1.2, %{})
2

iex> Liquex.Filter.ceil(2.0, %{})
2

iex> Liquex.Filter.ceil(183.357, %{})
184

iex> Liquex.Filter.ceil("3.5", %{})
4

compact(value, _)

@spec compact([any()], map()) :: [any()]

Removes any nil values from an array.

Examples

iex> Liquex.Filter.compact([1, 2, nil, 3], %{})
[1,2,3]

iex> Liquex.Filter.compact([1, 2, 3], %{})
[1,2,3]

compact(value, property, _)

Removes any items in the array whose property is nil.

Examples

iex> Liquex.Filter.compact([%{"a" => 1}, %{"a" => nil}, %{"a" => 2}], "a", %{})
[%{"a" => 1}, %{"a" => 2}]

concat(value, other, _)

Concatenates (joins together) multiple arrays. The resulting array contains all the items

Examples

iex> Liquex.Filter.concat([1,2], [3,4], %{})
[1,2,3,4]

date(value, format, context)

Converts value timestamp into another date format.

The format for this syntax is the same as strftime. The input uses the same format as Ruby’s Time.parse.

Examples

iex> Liquex.Filter.date(~D[2000-01-01], "%m/%d/%Y", %{})
"01/01/2000"

iex> Liquex.Filter.date("2000-01-01", "%m/%d/%Y", %{})
"01/01/2000"

iex> Liquex.Filter.date("January 1, 2000", "%m/%d/%Y", %{})
"01/01/2000"

iex> Liquex.Filter.date("1/2/2000", "%m/%d/%Y", %{})
"01/02/2000"

iex> Liquex.Filter.date("March 14, 2016", "%b %d, %y", %{})
"Mar 14, 16"

default(value, def_value, _)

Allows you to specify a fallback in case a value doesn’t exist. default will show its value if the left side is nil, false, or empty.

Examples

iex> Liquex.Filter.default("1.99", "2.99", %{})
"1.99"

iex> Liquex.Filter.default("", "2.99", %{})
"2.99"

iex> Liquex.Filter.default(false, "x", [{"allow_false", true}], %{})
false

iex> Liquex.Filter.default(false, "x", [{"allow_false", false}], %{})
"x"

default(value, def_value, options, context)

divided_by(value, divisor, _)

Divides a number by another number.

Examples

The result is rounded down to the nearest integer (that is, the floor) if the divisor is an integer.

iex> Liquex.Filter.divided_by(16, 4, %{})
4

iex> Liquex.Filter.divided_by(5, 3, %{})
1

iex> Liquex.Filter.divided_by(20, 5, %{})
4

iex> Decimal.equal?(Liquex.Filter.divided_by(20, 7.0, %{}), Decimal.new("2.857142857142857142857142857"))
true

downcase(value, _)

Makes each character in a string lowercase. It has no effect on strings which are already all lowercase.

Examples

iex> Liquex.Filter.downcase("Parker Moore", %{})
"parker moore"

iex> Liquex.Filter.downcase("apple", %{})
"apple"

escape(value, _)

Escapes a string by replacing characters with escape sequences (so that the string can be used in a URL, for example). It doesn’t change strings that don’t have anything to escape.

Examples

iex> Liquex.Filter.escape("Have you read 'James & the Giant Peach'?", %{})
"Have you read &#39;James &amp; the Giant Peach&#39;?"

iex> Liquex.Filter.escape("Tetsuro Takara", %{})
"Tetsuro Takara"

escape_once(value, _)

Escapes a string by replacing characters with escape sequences (so that the string can be used in a URL, for example). It doesn’t change strings that don’t have anything to escape.

Examples

iex> Liquex.Filter.escape_once("1 &lt; 2 &amp; 3", %{})
"1 &lt; 2 &amp; 3"

filter_name(arg)

@spec filter_name(filter_t()) :: String.t()

find(list, property, _)

Returns the first item in an array whose property is truthy. Returns nil if no item matches or the array is empty.

Examples

iex> Liquex.Filter.find([%{"v" => 1}, %{"v" => 2}], "v", 2, %{})
%{"v" => 2}

iex> Liquex.Filter.find([%{"v" => 1}, %{"v" => 2}], "v", %{})
%{"v" => 1}

iex> Liquex.Filter.find([], "v", 2, %{})
nil

find(list, property, target_value, _)

find_index(list, property, _)

Returns the index of the first item in an array whose property is truthy or matches target_value. Returns nil if no item matches or the array is empty.

Examples

iex> Liquex.Filter.find_index([%{"v" => 1}, %{"v" => 2}], "v", 2, %{})
1

iex> Liquex.Filter.find_index([%{"v" => 1}, %{"v" => 2}], "v", %{})
0

iex> Liquex.Filter.find_index([], "v", 2, %{})
nil

find_index(list, property, target_value, _)

first(arg1, _)

Returns the first item of an array.

Examples

iex> Liquex.Filter.first([1, 2, 3], %{})
1

iex> Liquex.Filter.first([], %{})
nil

floor(value, _)

@spec floor(binary() | number() | Decimal.t() | nil, any()) :: integer() | binary()

Rounds the input down to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.

Examples

iex> Liquex.Filter.floor(1.2, %{})
1

iex> Liquex.Filter.floor(2.0, %{})
2

has(list, property, _)

Returns true if any item in the array has the given property truthy or matching target_value, otherwise false. Returns false for empty arrays.

Examples

iex> Liquex.Filter.has([%{"v" => 1}, %{"v" => 2}], "v", 2, %{})
true

iex> Liquex.Filter.has([%{"v" => 1}], "v", 99, %{})
false

iex> Liquex.Filter.has([], "v", 2, %{})
false

has(list, property, target_value, _)

join(values, joiner, _)

Combines the items in values into a single string using joiner as a separator.

Examples

iex> Liquex.Filter.join(~w(John Paul George Ringo), " and ", %{})
"John and Paul and George and Ringo"

last(arr, context)

@spec last(any(), Liquex.Context.t()) :: any()

Returns the last item of arr.

Examples

iex> Liquex.Filter.last([1, 2, 3], %{})
3

iex> Liquex.Filter.first([], %{})
nil

lstrip(value, _)

@spec lstrip(String.t(), Liquex.Context.t()) :: String.t()

Removes all whitespace (tabs, spaces, and newlines) from the left side of a string. It does not affect spaces between words.

Examples

iex> Liquex.Filter.lstrip("          So much room for activities!          ", %{})
"So much room for activities!          "

map(arr, key, _)

@spec map([any()], term(), Liquex.Context.t()) :: [any()]

Creates an array (arr) of values by extracting the values of a named property from another object (key).

Examples

iex> Liquex.Filter.map([%{"a" => 1}, %{"a" => 2, "b" => 1}], "a", %{})
[1, 2]

minus(left, right, _)

@spec minus(number() | nil, number() | nil, Liquex.Context.t()) :: number()

Subtracts a number from another number.

Examples

iex> Liquex.Filter.minus(4, 2, %{})
2

iex> Liquex.Filter.minus(183, 12, %{})
171

iex> Decimal.equal?(Liquex.Filter.minus(183.357, 12, %{}), Decimal.new("171.357"))
true

modulo(left, right, _)

@spec modulo(number() | nil, number() | nil, Liquex.Context.t()) :: number()

Returns the remainder of a division operation.

Examples

iex> Liquex.Filter.modulo(3, 2, %{})
1

iex> Liquex.Filter.modulo(183, 12, %{})
3

iex> Decimal.equal?(Liquex.Filter.modulo(10.5, 3, %{}), Decimal.new("1.5"))
true

newline_to_br(value, _)

@spec newline_to_br(String.t(), Liquex.Context.t()) :: String.t()

Replaces every newline ( ) in a string with an HTML line break (<br />).

Examples

iex> Liquex.Filter.newline_to_br("\nHello\nthere\n", %{})
"<br />\nHello<br />\nthere<br />\n"

plus(left, right, _)

@spec plus(number() | nil, number() | nil, Liquex.Context.t()) :: number()

Adds a number to another number.

Examples

iex> Liquex.Filter.plus(4, 2, %{})
6

iex> Liquex.Filter.plus(183, 12, %{})
195

iex> Decimal.equal?(Liquex.Filter.plus(0.1, 0.2, %{}), Decimal.new("0.3"))
true

iex> Decimal.equal?(Liquex.Filter.plus(9.99, 14.5, %{}), Decimal.new("24.49"))
true

prepend(value, prepender, _)

Adds the specified string to the beginning of another string.

Examples

iex> Liquex.Filter.prepend("apples, oranges, and bananas", "Some fruit: ", %{})
"Some fruit: apples, oranges, and bananas"

iex> Liquex.Filter.prepend("/index.html", "example.com", %{})
"example.com/index.html"

reject(list, property, _)

Returns the items of an array whose property is falsy, or whose property is not equal to target_value when given.

Examples

iex> Liquex.Filter.reject([%{"v" => 1}, %{"v" => 2}, %{"v" => 3}], "v", 2, %{})
[%{"v" => 1}, %{"v" => 3}]

iex> Liquex.Filter.reject([%{"a" => true}, %{"a" => false}], "a", %{})
[%{"a" => false}]

reject(list, property, target_value, _)

remove(value, original, context)

Removes every occurrence of the specified substring from a string.

Examples

iex> Liquex.Filter.remove("I strained to see the train through the rain", "rain", %{})
"I sted to see the t through the "

remove_first(value, original, context)

Removes every occurrence of the specified substring from a string.

Examples

iex> Liquex.Filter.remove_first("I strained to see the train through the rain", "rain", %{})
"I sted to see the train through the rain"

remove_last(value, original, context)

Removes only the last occurrence of the specified substring from a string.

Examples

iex> Liquex.Filter.remove_last("I strained to see the train through the rain", "rain", %{})
"I strained to see the train through the "

replace(value, original, replacement, _)

Replaces every occurrence of the first argument in a string with the second argument.

Examples

iex> Liquex.Filter.replace("Take my protein pills and put my helmet on", "my", "your", %{})
"Take your protein pills and put your helmet on"

replace_first(value, original, replacement, _)

Replaces only the first occurrence of the first argument in a string with the second argument.

Examples

iex> Liquex.Filter.replace_first("Take my protein pills and put my helmet on", "my", "your", %{})
"Take your protein pills and put my helmet on"

replace_last(value, original, replacement, _)

Replaces only the last occurrence of the first argument in a string with the second argument. Returns the input unchanged if no occurrence is found.

Examples

iex> Liquex.Filter.replace_last("red, red, red", "red", "blue", %{})
"red, red, blue"

iex> Liquex.Filter.replace_last("abc", "x", "y", %{})
"abc"

reverse(arr, _)

Reverses the order of the items in an array. reverse cannot reverse a string.

Examples

iex> Liquex.Filter.reverse(~w(apples oranges peaches plums), %{})
["plums", "peaches", "oranges", "apples"]

round(value, precision \\ 0, context)

@spec round(binary() | number() | nil, binary() | number() | nil, Liquex.Context.t()) ::
  number()

Rounds a number to the nearest integer or, if a number is passed as an argument, to that number of decimal places.

Examples

iex> Liquex.Filter.round(1, %{})
1

iex> Liquex.Filter.round(1.2, %{})
1

iex> Liquex.Filter.round(2.7, %{})
3

iex> Liquex.Filter.round(183.357, 2, %{})
183.36

iex> Liquex.Filter.round(183.357, "invalid", %{})
183

iex> Liquex.Filter.round(183.357, 0, %{})
183

iex> Liquex.Filter.round(1234, -2, %{})
1200

iex> Liquex.Filter.round(183.357, -1, %{})
180

rstrip(value, _)

Removes all whitespace (tabs, spaces, and newlines) from the right side of a string. It does not affect spaces between words.

Examples

iex> Liquex.Filter.rstrip("          So much room for activities!          ", %{})
"          So much room for activities!"

size(value, _)

Returns the number of characters in a string or the number of items in an array.

Examples

iex> Liquex.Filter.size("Ground control to Major Tom.", %{})
28

iex> Liquex.Filter.size(~w(apples oranges peaches plums), %{})
4

slice(value, start, length \\ 1, _)

Returns a substring of 1 character beginning at the index specified by the first argument. An optional second argument specifies the length of the substring to be returned.

Examples

iex> Liquex.Filter.slice("Liquid", 0, %{})
"L"

iex> Liquex.Filter.slice("Liquid", 2, %{})
"q"

iex> Liquex.Filter.slice("Liquid", 2, 5, %{})
"quid"

If the first argument is a negative number, the indices are counted from the end of the string:

Examples

iex> Liquex.Filter.slice("Liquid", -3, 2, %{})
"ui"

Slicing an array returns a sub-array.

Examples

iex> Liquex.Filter.slice([1, 2, 3, 4, 5], 1, 2, %{})
[2, 3]

iex> Liquex.Filter.slice([1, 2, 3, 4, 5], 2, %{})
[3]

sort(list, _)

Sorts items in an array in case-sensitive order.

Examples

iex> Liquex.Filter.sort(["zebra", "octopus", "giraffe", "Sally Snake"], %{})
["Sally Snake", "giraffe", "octopus", "zebra"]

sort(list, field_name, _)

sort_natural(list, _)

Sorts items in an array in case-insensitive order.

Examples

iex> Liquex.Filter.sort_natural(["zebra", "octopus", "giraffe", "Sally Snake"], %{})
["giraffe", "octopus", "Sally Snake", "zebra"]

sort_natural(list, field_name, _)

split(value, separator, _)

Divides a string into an array using the argument as a separator. split is commonly used to convert comma-separated items from a string to an array.

Examples

iex> Liquex.Filter.split("John, Paul, George, Ringo", ", ", %{})
["John", "Paul", "George", "Ringo"]

strip(value, _)

Removes all whitespace (tabs, spaces, and newlines) from both the left and right side of a string. It does not affect spaces between words.

Examples

iex> Liquex.Filter.strip("          So much room for activities!          ", %{})
"So much room for activities!"

strip_html(value, _)

Removes any HTML tags from a string. The contents of <script>, <style>, and HTML comments are stripped along with the tags themselves, matching the Liquid gem's strip_html behavior.

Examples

iex> Liquex.Filter.strip_html("Have <em>you</em> read <strong>Ulysses</strong>?", %{})
"Have you read Ulysses?"

iex> Liquex.Filter.strip_html("<script>alert(1)</script>hi", %{})
"hi"

iex> Liquex.Filter.strip_html("<style>p {}</style>hi", %{})
"hi"

iex> Liquex.Filter.strip_html("a<!-- gone -->b", %{})
"ab"

strip_newlines(value, _)

Removes any newline characters (line breaks) from a string.

Examples

iex> Liquex.Filter.strip_newlines("Hello\nthere", %{})
"Hellothere"

sum(list, _)

Returns the sum of the items in an array. Items are coerced to numbers; with a property argument, the named property of each item is summed instead.

Examples

iex> Liquex.Filter.sum([1, 2, 3], %{})
6

iex> Liquex.Filter.sum([%{"v" => 1}, %{"v" => 2}], "v", %{})
3

iex> Liquex.Filter.sum([], %{})
0

sum(list, property, _)

times(value, divisor, _)

Multiplies a number by another number.

Examples

iex> Liquex.Filter.times(3, 4, %{})
12

iex> Liquex.Filter.times(24, 7, %{})
168

iex> Liquex.Filter.times(7, 12, %{})
84

iex> Decimal.equal?(Liquex.Filter.times(9.99, 2, %{}), Decimal.new("19.98"))
true

truncate(value, length, ellipsis \\ "...", _)

Shortens a string down to the number of characters passed as an argument. If the specified number of characters is less than the length of the string, an ellipsis (…) is appended to the string and is included in the character count.

Examples

iex> Liquex.Filter.truncate("Ground control to Major Tom.", 20, %{})
"Ground control to..."

iex> Liquex.Filter.truncate("Ground control to Major Tom.", 25, ", and so on", %{})
"Ground control, and so on"

iex> Liquex.Filter.truncate("Ground control to Major Tom.", 20, "", %{})
"Ground control to Ma"

truncatewords(value, length, ellipsis \\ "...", _)

Shortens a string down to the number of characters passed as an argument. If the specified number of characters is less than the length of the string, an ellipsis (…) is appended to the string and is included in the character count.

Examples

iex> Liquex.Filter.truncatewords("Ground control to Major Tom.", 3, %{})
"Ground control to..."

iex> Liquex.Filter.truncatewords("Ground control to Major Tom.", 3, "--", %{})
"Ground control to--"

iex> Liquex.Filter.truncatewords("Ground control to Major Tom.", 3, "", %{})
"Ground control to"

iex> Liquex.Filter.truncatewords("a b c d e", 0, %{})
"a..."

uniq(list, _)

Removes any duplicate elements in an array.

Examples

iex> Liquex.Filter.uniq(~w(ants bugs bees bugs ants), %{})
["ants", "bugs", "bees"]

uniq(list, property, _)

Removes items from an array that share a value at the given property.

Examples

iex> Liquex.Filter.uniq([%{"id" => 1}, %{"id" => 2}, %{"id" => 1}], "id", %{})
[%{"id" => 1}, %{"id" => 2}]

upcase(value, _)

Makes each character in a string uppercase. It has no effect on strings which are already all uppercase.

Examples

iex> Liquex.Filter.upcase("Parker Moore", %{})
"PARKER MOORE"

iex> Liquex.Filter.upcase("APPLE", %{})
"APPLE"

url_decode(value, _)

Decodes a string that has been encoded as a URL or by url_encode/2.

Examples

iex> Liquex.Filter.url_decode("%27Stop%21%27+said+Fred", %{})
"'Stop!' said Fred"

url_encode(value, _)

Decodes a string that has been encoded as a URL or by url_encode/2.

Examples

iex> Liquex.Filter.url_encode("john@liquid.com", %{})
"john%40liquid.com"

iex> Liquex.Filter.url_encode("Tetsuro Takara", %{})
"Tetsuro+Takara"

where(list, key, _)

Creates an array including only the objects with a given truthy property value

Examples

iex> Liquex.Filter.where([%{"b" => true, "value" => 1}, %{"b" => 1, "value" => 2}, %{"b" => false, "value" => 3}], "b", %{})
[%{"b" => true, "value" => 1}, %{"b" => 1, "value" => 2}]

where(list, key, value, _)

Creates an array including only the objects with a given property value, or any truthy value by default.

Examples

iex> Liquex.Filter.where([%{"b" => 2}, %{"b" => 1}], "b", 1, %{})
[%{"b" => 1}]