A Clojure wrapper around StringTemplate.
This is a Proof of concept. Do not use in production.
- A paper "Enforcing Strict Model-View Separation in Template Engines" by Terence Parr.
- Cover the monstrosity of Java with joy and loveliness of Clojure
- Labor est etiam ipse voluptas
(require '[com.github.akond.string-template.core :as st])
(let [t (st/template "Hello, <name>!")]
(-> t (merge {:name "world"}) str))
=> "Hello, world!"
(let [g (st/group (io/file "example.stg"))]
(-> g :greet (merge {:hellos ["Hi" "Guten morgen" "Buenos dias"]}) print))
=>
Hi, world!
Guten morgen, world!
Buenos dias, world!
File example.stg
:
greet(hellos) ::= <<
<hellos: world()>
>>
world(item) ::= <<
<item>, world!
>>
See more examples in the tests.