Created
July 25, 2013 06:13
-
-
Save leobm/6077287 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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