View Source Liquor.Tags (Liquor Tags v1.0.2)

Tags finds the "Liquor Tags" inside a plain text document. Eg: {% embed https://ninjas.cl %} then fetches the open graph data from the url and renders using a pseudo EEx template.

Summary

Functions

Finds the tags inside a document. And generate an output with the open graph data for each match.

Given a list of tags with open graph data. Replace each tag with the rendered output from the tag.

Types

@type t() :: [%{tags: [Liquor.Tags.Tag.t()], content: String.t()}]

Functions

@spec find(Liquor.t()) :: %{content: String.t(), tags: [Liquor.Tags.Tag.t()]}

Finds the tags inside a document. And generate an output with the open graph data for each match.

Examples

iex> Liquor.init("{% embed https://ninjas.cl %}", [Liquor.Tags.Tag.new("embed", "<%= og.url %>")], fn url -> Req.get!(url) |> then(& &1.body) end) |> Liquor.Tags.find() |> then(& List.first(&1.tags)) |> then(& List.first(&1.matches).output)
"https://ninjas.cl"
@spec render(t()) :: String.t()

Given a list of tags with open graph data. Replace each tag with the rendered output from the tag.

Examples

iex> Liquor.init("{% embed https://ninjas.cl %}", [Liquor.Tags.Tag.new("embed", "<%= og.url %>")], fn url -> Req.get!(url) |> then(& &1.body) end) |> Liquor.Tags.find() |> Liquor.Tags.render()
"https://ninjas.cl"