Created
June 25, 2017 10:25
-
-
Save antoniogarrote/65765e34802bdc841fed566c9dda7a26 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
(defn apply-template [uri parameters {:keys [result]}] | |
(reduce (fn [acc {:keys [name property]}] | |
(let [value (get result property) | |
value (or (get value "@value") (get value "@id"))] | |
(if (nil? value) | |
(throw (Exception. (str "Missing parameter " name " for template " uri))) | |
(string/replace uri (str "{" name "}") (str value))))) | |
uri | |
parameters)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment