# `Markup.Djot.Attributes`
[🔗](https://github.com/paradox460/markup/blob/markup_djot-v0.1.0/markup_djot/lib/markup/djot/attributes.ex#L1)

Helpers for node attribute lists.

Attributes are an ordered list of `{key, value}` string pairs. Order and
duplicates are preserved; multiple `"class"` entries are joined when rendered.

# `t`

```elixir
@type t() :: [{String.t(), String.t()}]
```

# `add_class`

```elixir
@spec add_class(t(), String.t()) :: t()
```

Appends a class.

# `delete`

```elixir
@spec delete(t(), String.t()) :: t()
```

Removes every entry for `key`.

# `get`

```elixir
@spec get(t(), String.t()) :: String.t() | nil
```

Returns the value for `key`.

For `"class"`, all class values joined with a space. For other keys, the last value.
Returns `nil` when the key is absent.

    iex> Markup.Djot.Attributes.get([{"class", "a"}, {"id", "x"}, {"class", "b"}], "class")
    "a b"
    iex> Markup.Djot.Attributes.get([{"id", "x"}, {"id", "y"}], "id")
    "y"

# `put`

```elixir
@spec put(t(), String.t(), String.t()) :: t()
```

Replaces every entry for `key` with a single `{key, value}` at the end.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
