Current section

Files

Jump to
yuri_template lib yuri_template unsafe_expander.ex
Raw

lib/yuri_template/unsafe_expander.ex

defmodule YuriTemplate.UnsafeExpander do
@moduledoc false
@behaviour YuriTemplate.Expander
@impl true
def expand(acc, _substitutes, []), do: acc
def expand(acc, substitutes, [var | vars]) do
case Access.fetch(substitutes, var) do
:error ->
acc
{:ok, v} when is_binary(v) ->
[v | acc]
end
|> expand(substitutes, vars)
end
end