Packages

Advent of code helper - automating setup of tests, solution template and problem input

Current section

Files

Jump to
adglent src priv template.gleam
Raw

src/priv/template.gleam

import gleam/list
import gleam/string
pub fn render(
template: String,
substitutions: List(#(String, String)),
) -> String {
substitutions
|> list.fold(
template,
fn(template, substitution) {
let #(name, value) = substitution
template
|> string.replace("{{ " <> name <> " }}", value)
},
)
|> string.trim <> "\n"
}