Compiles the clj-format s-expression DSL into cl-format format strings.
The inverse of clj-format.parser/parse-format. Takes a DSL body vector and produces the equivalent cl-format string.
Examples: (compile-format :str) => "~A" (compile-format [:str]) => "~A" (compile-format ["Hello " :str "!"]) => "Hello ~A!" (compile-format [:cardinal " file" [:plural {:rewind true}]]) => "~R file~:P" (compile-format [[:each {:sep ", "} :str]]) => "~{~A~^, ~}" (compile-format [[:if "yes" "no"]]) => "~:[no~;yes~]"
Compiles the clj-format s-expression DSL into cl-format format strings.
The inverse of clj-format.parser/parse-format. Takes a DSL body vector
and produces the equivalent cl-format string.
Examples:
(compile-format :str) => "~A"
(compile-format [:str]) => "~A"
(compile-format ["Hello " :str "!"]) => "Hello ~A!"
(compile-format [:cardinal " file" [:plural {:rewind true}]])
=> "~R file~:P"
(compile-format [[:each {:sep ", "} :str]]) => "~{~A~^, ~}"
(compile-format [[:if "yes" "no"]]) => "~:[no~;yes~]"(compile-format dsl)Compile a DSL form into a cl-format format string.
Accepts:
Examples: (compile-format :str) ;=> "~A" (compile-format [:str]) ;=> "~A" (compile-format [:str {:width 10}]) ;=> "~10A" (compile-format ["Hello " :str "!"]) ;=> "Hello ~A!" (compile-format [:cardinal " file" [:plural {:rewind true}]]) ;=> "~R file~:P" (compile-format [:each {:sep ", "} :str]) ;=> "~{~A~^, ~}" (compile-format [:if "yes" "no"]) ;=> "~:[no~;yes~]"
Compile a DSL form into a cl-format format string.
Accepts:
- a body vector of elements: ["Hello " :str "!"]
- a single directive vector: [:each {:sep ", "} :str]
- a bare keyword: :str
Examples:
(compile-format :str) ;=> "~A"
(compile-format [:str]) ;=> "~A"
(compile-format [:str {:width 10}]) ;=> "~10A"
(compile-format ["Hello " :str "!"]) ;=> "Hello ~A!"
(compile-format [:cardinal " file" [:plural {:rewind true}]])
;=> "~R file~:P"
(compile-format [:each {:sep ", "} :str]) ;=> "~{~A~^, ~}"
(compile-format [:if "yes" "no"]) ;=> "~:[no~;yes~]"cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |