Skip to content

Instantly share code, notes, and snippets.

@antoniogarrote
Created June 25, 2017 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoniogarrote/ee8e60ea0eb531dd5657c991fad28ba7 to your computer and use it in GitHub Desktop.
Save antoniogarrote/ee8e60ea0eb531dd5657c991fad28ba7 to your computer and use it in GitHub Desktop.
(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