Skip to content

Instantly share code, notes, and snippets.

@leobm
Created July 25, 2013 06:13
Show Gist options
  • Save leobm/6077287 to your computer and use it in GitHub Desktop.
Save leobm/6077287 to your computer and use it in GitHub Desktop.
;; Simple solution for argument replacement in a string
(defn replace-templates3 [text m]
(clojure.string/replace text
#"\{\w+\}"
(fn [groups]
((->> groups
reverse
(drop 1)
reverse
(drop 1)
(apply str)
keyword) m))))
;; usage
(replace-template3 "{myvar} text text" {:myvar “abc"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment