# `Ltix.DeepLinking.ContentItem.HTMLFragment`
[🔗](https://github.com/DecoyLex/ltix/blob/main/lib/ltix/deep_linking/content_item/html_fragment.ex#L1)

An HTML fragment content item for Deep Linking responses.

Represents a chunk of HTML that the platform embeds directly.

## Examples

    iex> {:ok, fragment} = Ltix.DeepLinking.ContentItem.HTMLFragment.new(html: "<p>Hello</p>")
    iex> Ltix.DeepLinking.ContentItem.to_map(fragment)
    %{"type" => "html", "html" => "<p>Hello</p>"}

## Options

* `:title` (`t:String.t/0`) - Title for the content item.

* `:text` (`t:String.t/0`) - Plain-text description.

* `:extensions` (`nil` | `t:map/0`) - Required. Vendor-specific extension properties. The default value is `%{}`.

* `:html` (`t:String.t/0`) - Required. HTML markup to embed.

# `t`

```elixir
@type t() :: %Ltix.DeepLinking.ContentItem.HTMLFragment{
  extensions: nil | %{optional(binary() | atom()) =&gt; any()},
  html: binary(),
  text: nil | binary(),
  title: nil | binary()
}
```

# `new`

```elixir
@spec new(keyword() | map()) :: {:ok, t()} | {:error, Exception.t()}
```

Create a new HTML fragment content item.

Takes the module's options as a keyword list or map. Unknown or invalid options return
an `Ltix.Errors.Invalid.InvalidField` error.

## Examples

    iex> {:ok, fragment} = Ltix.DeepLinking.ContentItem.HTMLFragment.new(html: "<p>Hello</p>")
    iex> fragment.html
    "<p>Hello</p>"

    iex> {:error, error} = Ltix.DeepLinking.ContentItem.HTMLFragment.new([])
    iex> Exception.message(error)
    "Ltix.DeepLinking.ContentItem.HTMLFragment field :html is required [DL §3.4]"

# `new!`

```elixir
@spec new!(keyword() | map()) :: t()
```

Same as `new/1` but raises on error.

## Examples

    iex> Ltix.DeepLinking.ContentItem.HTMLFragment.new!(html: "<p>Hello</p>").html
    "<p>Hello</p>"

---

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