I have a template file with a few placeholders. I want to replace the placeholders with actual values and pipe the result forward.
Currently I read the whole file, find all occurrences of the placeholders and replace them with their respective (pre-calculated) values, and then push that into some pipe (see example bellow).
Is there some better way of doing this (like connecting the pipe with some filter/switch in between)?
open("file.txt", "w") do o txt = readstring("template_file.txt") for (k, v) in Dict("PLACEHOLDER1" => 3, "PLACEHOLDER2" => "this") txt = replace(txt, k, v) end print(o, txt) end
apples: PLACEHOLDER1 and then: PLACEHOLDER2
This results in
apples: 3 and then: this