1.2.0 permalink Arrow_down_16x16

apply-template

clojure.contrib.test-is

  • (apply-template expr values)
Replaces _1, _2, _3, etc. in expr with corresponding elements of
values. Returns the modified expression. For use in macros.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/test_is.clj:77 top

(defn apply-template
  "Replaces _1, _2, _3, etc. in expr with corresponding elements of
  values.  Returns the modified expression.  For use in macros."
  [expr values]
  (when-not (template? expr)
    (throw (IllegalArgumentException. (str (pr-str expr) " is not a valid template."))))
  (let [expr (walk/postwalk-replace {'_ '_1} expr)
        holes (find-holes expr)
        smap (zipmap holes values)]
    (walk/prewalk-replace smap expr)))
Vars in clojure.contrib.test-is/apply-template: defn let pr-str str when-not
Used in 0 other vars

Comments top

No comments for apply-template. Log in to add a comment.