Liking cljdoc? Tell your friends :D

Clojars Project

A Clojure wrapper around StringTemplate.

This is a Proof of concept. Do not use in production.

Rationale

  • 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

Resources

Examples

Hello, world

(require '[com.github.akond.string-template.core :as st])
(let [t (st/template "Hello, <name>!")]
	(-> t (merge {:name "world"}) str))
=> "Hello, world!"

Using template groups

(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.

Can you improve this documentation? These fine people already did:
Toropenko Sergey & Sergey Toropenko
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close