Skip to content

Instantly share code, notes, and snippets.

@sundarj
Created November 7, 2017 23:14
Show Gist options
  • Save sundarj/f2083c102d09e01f9323ce16431eabb6 to your computer and use it in GitHub Desktop.
Save sundarj/f2083c102d09e01f9323ce16431eabb6 to your computer and use it in GitHub Desktop.
(defn render-pattern [pattern replacements-map]
(for [item pattern] (if (symbol? item) (get replacements-map item) item)))
#'boot.user/render-pattern
(render-pattern
`["my apple is named " ?apple-name " and i hate " ?hated-thing]
`{?apple-name "peter", ?hated-thing "imperative programming"})
("my apple is named " "peter" " and i hate " "imperative programming")
(apply str *1)
"my apple is named peter and i hate imperative programming"
@sundarj
Copy link
Author

sundarj commented Nov 7, 2017

`["my apple is named " ?apple-name " and i hate " ?hated-thing]
["my apple is named " boot.user/?apple-name " and i hate " boot.user/?hated-thing]

`{?apple-name "peter", ?hated-thing "imperative programming"}
#:boot.user{?hated-thing "imperative programming", ?apple-name "peter"}

;;and they're automatically namespace-qualified (to avoid clashes)```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment