aboutsummaryrefslogtreecommitdiff
path: root/aoc2023/build/packages/adglent/src/priv@template.erl
diff options
context:
space:
mode:
authorHJ <thechairman@thechairman.info>2024-02-03 15:09:54 -0500
committerHJ <thechairman@thechairman.info>2024-02-03 15:09:54 -0500
commit96a3c5c179d8d3fff24eb2953e45f8dd15e2714c (patch)
tree0a67bc0cfeabe51740bb049c61f16f1ac3bdd4ff /aoc2023/build/packages/adglent/src/priv@template.erl
parent547fe03cf43105f46160e2dd9afff21637eaaf47 (diff)
downloadgleam_aoc-96a3c5c179d8d3fff24eb2953e45f8dd15e2714c.tar.gz
gleam_aoc-96a3c5c179d8d3fff24eb2953e45f8dd15e2714c.zip
cleanup
Diffstat (limited to 'aoc2023/build/packages/adglent/src/priv@template.erl')
-rw-r--r--aoc2023/build/packages/adglent/src/priv@template.erl25
1 files changed, 25 insertions, 0 deletions
diff --git a/aoc2023/build/packages/adglent/src/priv@template.erl b/aoc2023/build/packages/adglent/src/priv@template.erl
new file mode 100644
index 0000000..6a5d0bf
--- /dev/null
+++ b/aoc2023/build/packages/adglent/src/priv@template.erl
@@ -0,0 +1,25 @@
+-module(priv@template).
+-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]).
+
+-export([render/2]).
+
+-spec render(binary(), list({binary(), binary()})) -> binary().
+render(Template, Substitutions) ->
+ <<(begin
+ _pipe = Substitutions,
+ _pipe@2 = gleam@list:fold(
+ _pipe,
+ Template,
+ fun(Template@1, Substitution) ->
+ {Name, Value} = Substitution,
+ _pipe@1 = Template@1,
+ gleam@string:replace(
+ _pipe@1,
+ <<<<"{{ "/utf8, Name/binary>>/binary, " }}"/utf8>>,
+ Value
+ )
+ end
+ ),
+ gleam@string:trim(_pipe@2)
+ end)/binary,
+ "\n"/utf8>>.