I am going to store string email templates in my database; the program will select a template and provide a map to replace the template variables within the string. This seems like an obvious thing to do (it is nearly accomplished with good 'ol format
), but I have yet to spot any clear libraries or functions that take care of it. Below is the use I have in mind; anyone know of existing solutions here?
(deftest templating
(let [replacement-map {:user "Gandalf"
:spell "Incendio"
:species "Borg"}
replacement-string ":user, a :species, cast :spell"]
(is (= (unwritten-function replacement-string replacement-map)
"Gandalf, a Borg, cast Incendio"))))