Tiptapex.Renderer.HTML (Tiptapex v0.1.0)

Copy Markdown View Source

Safe HTML building blocks for Tiptapex.Renderer.

Every attribute value passes through Phoenix.HTML.attributes_escape/1 and every text chunk through Phoenix.HTML.html_escape/1 — nothing is ever string-interpolated into markup. All functions return iodata; the renderer wraps the final result in {:safe, iodata}.

Summary

Functions

Escapes a text chunk, returning iodata.

Joins property: value pairs into a style attribute value, skipping blank entries. Returns nil when nothing remains so the attribute is dropped entirely.

Builds <name attrs>children</name> as iodata.

Builds a void element <name attrs> as iodata.

Functions

escape(text)

@spec escape(term()) :: iodata()

Escapes a text chunk, returning iodata.

style(pairs)

@spec style([{binary(), binary() | nil}]) :: binary() | nil

Joins property: value pairs into a style attribute value, skipping blank entries. Returns nil when nothing remains so the attribute is dropped entirely.

tag(name, attrs, children)

@spec tag(binary(), Enumerable.t(), iodata()) :: iodata()

Builds <name attrs>children</name> as iodata.

Attribute values that are nil, false, or "" are dropped.

void_tag(name, attrs)

@spec void_tag(binary(), Enumerable.t()) :: iodata()

Builds a void element <name attrs> as iodata.