Search code examples
stringclojuretemplate-engine

Lightweight Clojure library for simple string templating?


I'm looking for a (preferably small) Clojure library that is available in clojars which allows me to replace simple templates in strings such as:

"Hello my name is ${name}"

where ${name} should be replaced by the template engine. In Java I usually use JMTE that works perfectly. I know that I can probably use it from Clojure as well but I wonder if there's something that is more Clojure friendly/idiomatic.


Solution

  • There are quite a lot of templating libraries. Some general purpose ones are:

    Note: If you just need to have some clever formatting, you have the standard library clojure.pprint with the cl-format function and clojure.core/format which is the wrapper around java.util.Formatter.