Idiom.Interpolation (idiom v0.1.0)

Functionality for interpolating variables into a message string.

Summary

Functions

Interpolates a message string with a map of bindings.

Functions

Link to this function

interpolate(message, bindings)

Interpolates a message string with a map of bindings.

The message string can include variables wrapped in {{}}. For example, in the string Hello, {{name}}!, {{name}} is a variable.
If a variable exists in the message string, but not in the bindings, it is converted to a string in-place.

Examples

iex> Idiom.Interpolation.interpolate("Hello, {{name}}!", %{name: "John"})
"Hello, John!"

iex> Idiom.Interpolation.interpolate("Hello, {{name}}! It is {{day_of_week}}.", %{name: "John", day_of_week: "Monday"})
"Hello, John! It is Monday."

iex> Idiom.Interpolation.interpolate("Hello, {{name}}! It is {{day_of_week}}.", %{name: "John"})
"Hello, John! It is day_of_week."