ExClsx
An utility module to concatenate strings fragments, filtering falsey values. Inspired to clsx, it is useful to produce class names for components that depend on component attributes.
Installation
If available in Hex, the package can be installed
by adding ex_clsx to your list of dependencies in mix.exs:
def deps do
[
{:ex_clsx, "~> 0.1.0"}
]
endUsage
iex> ExClsx.clsx(["hello", "world"])
"hello world"
iex> ExClsx.clsx(["hello", false, 0, nil, "world"])
"hello world"
iex> ExClsx.clsx(["please", %{ keep: true, discard: false }])
"please keep"
iex> ExClsx.clsx(["please", %{ "keep" => true, "discard" => false }])
"please keep"Use cases
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ex_clsx.