Yamel (yamel v1.0.4) View Source

Module to work with YAML strings in Elixir.

Link to this section Summary

Functions

Encodes a YAML term. Returns {:ok, yaml()} where the second term is the encoded YAML term. Otherwise, returns {:error, reason} with reason being a string stating the error reason.

Encodes a YAML term directly into a string, throwing an exception if the term can not be encoded.

Link to this section Types

Specs

decode_opt() :: {:keys, keys()}

Specs

keys() :: :atoms | :strings

Specs

t() :: map() | list()

Specs

yaml() :: binary()

Link to this section Functions

Link to this function

decode(yaml_string, options \\ [])

View Source

Specs

decode(yaml(), [decode_opt()]) :: {:ok, t()} | {:error, reason :: binary()}
Link to this function

decode!(yaml_string, options \\ [])

View Source

Specs

decode!(yaml(), [decode_opt()]) :: t()

Specs

encode(t()) :: {:ok, yaml()} | {:error, reason :: binary()}

Encodes a YAML term. Returns {:ok, yaml()} where the second term is the encoded YAML term. Otherwise, returns {:error, reason} with reason being a string stating the error reason.

Examples

iex> Yamel.encode(["foo", "bar", "baz"])
{:ok, "- foo\n- bar\n- baz\n\n"}

Specs

encode!(t()) :: yaml()

Encodes a YAML term directly into a string, throwing an exception if the term can not be encoded.

Examples

iex> Yamel.encode!(["foo", "bar", "baz"])
"- foo\n- bar\n- baz\n\n"