(named-format format-string arg-map)
Like clojure.core/format but uses named args. format-string
is
similar to that accepted by clojure.core/format, but with names on
each formatting expression. arg-map
is a map with keyword keys
matching the names used in the format string. E.g.,:
(named-format "Hello my name is %name~s and I am %height~.3f feet tall." {:name "Joe Biden" :height (* 2 Math/PI)}) ;; => "Hello my name is Joe Biden and I am 6.283 feet tall."
Names are terminated with a ~ character, and immediately following the ~ should be a format specifier as per clojure.core/format.
Like clojure.core/format but uses named args. `format-string` is similar to that accepted by clojure.core/format, but with names on each formatting expression. `arg-map` is a map with keyword keys matching the names used in the format string. E.g.,: (named-format "Hello my name is %name~s and I am %height~.3f feet tall." {:name "Joe Biden" :height (* 2 Math/PI)}) ;; => "Hello my name is Joe Biden and I am 6.283 feet tall." Names are terminated with a \~ character, and immediately following the \~ should be a format specifier as per clojure.core/format.
(parse-named-format-string format-str)
Given a format string as described by the docstring on the named-format
function, returns a pair [clojure-format-string names] where
clojure-format-string
is a similar format string suitable to pass
to clojure.core/format, and names
is a vector of keywords
representing the names used in the format specifiers in the input
string.
Given a format string as described by the docstring on the named-format function, returns a pair [clojure-format-string names] where `clojure-format-string` is a similar format string suitable to pass to clojure.core/format, and `names` is a vector of keywords representing the names used in the format specifiers in the input string.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close