SchemaOrg.HTML (SchemaOrg v0.2.0)

Copy Markdown View Source

Phoenix function components for embedding Schema.org JSON-LD.

This module exists only when Phoenix.Component is available — add :phoenix_live_view to your app's dependencies to use it. It is a thin, HTML-safe wrapper over SchemaOrg.to_script_tag/1.

Summary

Functions

Renders a <script type="application/ld+json"> tag for a SchemaOrg struct, or a list of structs (emitted as a single @graph).

Functions

json_ld(assigns)

Renders a <script type="application/ld+json"> tag for a SchemaOrg struct, or a list of structs (emitted as a single @graph).

<SchemaOrg.HTML.json_ld data={@product} />
<SchemaOrg.HTML.json_ld data={[@organization, @website]} />

The output is HTML-safe: a value containing </script> cannot break out of the tag (see SchemaOrg.to_script_tag/1).

Attributes

  • data (:any) (required) - a SchemaOrg struct or a list of them.