API for strint - clojure-contrib v1.3 (in development)

by Chas Emerick

clojure-contrib is now deprecated

clojure-contrib is no longer being developed or maintained.

Rather than a single, monolithic, contributions library, Clojure now has a set of separate libraries for each unit of functionality. The libraries are in the Clojure GitHub organization at https://github.com/clojure. API documentation of the libraries can be found at https://clojure.github.io.

If you're looking for a specific function or namespace from the old clojure-contrib, see "Where Did Clojure.Contrib Go".


Full namespace name: clojure.contrib.strint

Overview

String interpolation for Clojure.

Public Variables and Functions



<<

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (<< string)
Takes a single string argument and emits a str invocation that concatenates
the string data and evaluated expressions contained within that argument.
Evaluation is controlled using ~{} and ~() forms.  The former is used for
simple value replacement using clojure.core/str; the latter can be used to
embed the results of arbitrary function invocation into the produced string.

Examples:
user=> (def v 30.5)
#'user/v
user=> (<< "This trial required ~{v}ml of solution.")
"This trial required 30.5ml of solution."
user=> (<< "There are ~(int v) days in November.")
"There are 30 days in November."
user=> (def m {:a [1 2 3]})
#'user/m
user=> (<< "The total for your order is $~(->> m :a (apply +)).")
"The total for your order is $6."

Note that quotes surrounding string literals within ~() forms must be
escaped.
Source
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.