aboutsummaryrefslogtreecommitdiff
path: root/aoc2023/build/packages/adglent/src/priv@template.erl
diff options
context:
space:
mode:
authorJ.J <thechairman@thechairman.info>2024-05-30 21:50:02 -0400
committerJ.J <thechairman@thechairman.info>2024-05-30 21:50:02 -0400
commit612fd986ab1e00b6d34dc1937136250e08e89325 (patch)
treea3c93952040c6afdf348b5831619a45db7ba0a2e /aoc2023/build/packages/adglent/src/priv@template.erl
parent231c2b688d1e6cf0846d46e883da30e042a9c6cf (diff)
downloadgleam_aoc-612fd986ab1e00b6d34dc1937136250e08e89325.tar.gz
gleam_aoc-612fd986ab1e00b6d34dc1937136250e08e89325.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>>.