solid v0.0.2 Solid.Filter

Standard filters

Summary

Functions

Apply filter if it exists. Otherwise return the first input

Removes all occurrences of nil from a list

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

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

Join a list of strings returning one String glued by `glue

Map through a list of hashes accessing property

Replaces every occurrence of an argument in a string with the second argument

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

Functions

apply(filter, args)

Apply filter if it exists. Otherwise return the first input.

iex> Solid.Filter.apply(“upcase”, ["ac"]) “AC” iex> Solid.Filter.apply(“no_filter_here”, [1, 2, 3]) 1

compact(input)

Specs

compact(list) :: list

Removes all occurrences of nil from a list

iex> Solid.Filter.compact([1, nil, 2, nil, 3]) [1, 2, 3]

compact(input, property)
default(input, value)

Specs

default(any, any) :: any

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

iex> Solid.Filter.default(123, 456) 123

iex> Solid.Filter.default(nil, 456) 456

iex> Solid.Filter.default(false, 456) 456

iex> Solid.Filter.default([], 456) 456

downcase(input)

Specs

downcase(any) :: String.t

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

iex> Solid.Filter.downcase(“aBc”) “abc”

iex> Solid.Filter.downcase(456) “456”

iex> Solid.Filter.downcase(nil) “”

join(input, glue \\ " ")

Specs

join(list, String.t) :: String.t

Join a list of strings returning one String glued by `glue iex> Solid.Filter.join(["a", "b", "c"]) “a b c” iex> Solid.Filter.join(["a", "b", "c"], “-“) “a-b-c”

map(input, property)

Map through a list of hashes accessing property

iex> Solid.Filter.map([%{"a" => "A"}, %{"a" => 1}], “a”) ["A", 1]

replace(input, string, replacement \\ "")

Specs

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

iex> Solid.Filter.replace(“Take my protein pills and put my helmet on”, “my”, “your”) “Take your protein pills and put your helmet on”

upcase(input)

Specs

upcase(any) :: String.t

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

iex> Solid.Filter.upcase(“aBc”) “ABC”

iex> Solid.Filter.upcase(456) “456”

iex> Solid.Filter.upcase(nil) “”