View Source Yex.XmlTextPrelim (y_ex v0.6.3)
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"}]
Summary
Functions
Transforms a Text to a TextPrelim
Types
@type t() :: %Yex.XmlTextPrelim{ attributes: %{required(binary()) => binary()}, delta: Yex.Text.delta() }
Functions
@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"}]