Bobbin.Template (bobbin v0.5.1)

Copy Markdown View Source

Reads values from a run's context, and fills {{name}} placeholders with them.

A name can be a dotted path, like body.user.name, where a number picks an item of a list, like body.items.0.name. Flow variables come first, then the context.

Summary

Functions

Reads a template that holds JSON, and returns the value it describes.

Functions

fetch(context, path)

json(template, context, check \\ fn _value -> :ok end)

Reads a template that holds JSON, and returns the value it describes.

The JSON is parsed before anything is filled in, so what a run brings is data and can't change the shape the flow's author wrote. A placeholder outside a string takes the value as it is, and one inside a string is written into that string.

check sees each of those values and can refuse one with {:error, message}.

render(template, context)