# `Yex.XmlTextPrelim`
[🔗](https://github.com/satoren/y_ex/blob/main/lib/shared_type/xml_text.ex#L232)

A preliminary xml text. It can be used to early initialize the contents of a XmlText.

## Examples
    iex> doc = Yex.Doc.new()
    iex> xml = Yex.Doc.get_xml_fragment(doc, "xml")
    iex> Yex.XmlFragment.insert(xml, 0,  Yex.XmlTextPrelim.from("Hello World"))
    iex> {:ok, %Yex.XmlText{} = text} = Yex.XmlFragment.fetch(xml, 0)
    iex> Yex.XmlText.to_delta(text)
    [%{insert: "Hello World"}]

# `t`

```elixir
@type t() :: %Yex.XmlTextPrelim{
  attributes: %{required(binary()) =&gt; binary()},
  delta: Yex.Text.delta()
}
```

# `from`

```elixir
@spec from(binary()) :: t()
@spec from(Yex.Text.delta()) :: t()
```

Transforms a Text to a TextPrelim
## Examples with a binary
    iex> doc = Yex.Doc.new()
    iex> map = Yex.Doc.get_map(doc, "map")
    iex> Yex.Map.set(map, "key", Yex.XmlTextPrelim.from("Hello World"))
    iex> {:ok, %Yex.XmlText{} = text} = Yex.Map.fetch(map, "key")
    iex> Yex.XmlText.to_delta(text)
    [%{insert: "Hello World"}]

## Examples with delta
    iex> doc = Yex.Doc.new()
    iex> map = Yex.Doc.get_map(doc, "map")
    iex> Yex.Map.set(map, "key", Yex.XmlTextPrelim.from([%{insert: "Hello"},%{insert: " World", attributes: %{ "bold" => true }},]))
    iex> {:ok,%Yex.XmlText{} = text} = Yex.Map.fetch(map, "key")
    iex> Yex.XmlText.to_delta(text)
    [%{insert: "Hello"}, %{attributes: %{"bold" => true}, insert: " World"}]

---

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