A thin wrapper around jade4j to promote use with the Clojure community.
[clj-jade "0.1.2"]
index.jade
!!! 5
html
head
title= pageName
body
ol.guitars
for guitar in guitars
li #{guitar.maker} #{guitar.model}
(require '[clj-jade.core :as jade])
(jade/render "index.jade" {"pageName" "My Guitars"
"guitars" [{"model" "Hummingbird" "maker" "Gibson"}
{"model" "Telecaster" "maker" "Fender"}]})
Produces:
<!DOCTYPE html>
<html>
<head>
<title>My Guitars</title>
</head>
<body>
<ol class="guitars">
<li>Gibson Hummingbird</li>
<li>Fender Telecaster</li>
</ol>
</body>
</html>
The default clj-jade configuration can be configured as follows.
(require '[clj-jade.core :as jade])
(jade/configure {:template-dir "examples/templates/"
:pretty-print true
:cache? true})
(jade/render "index.jade" {"pageName" "My Guitars"
"guitars" [{"model" "Hummingbird" "maker" "Gibson"}
{"model" "Telecaster" "maker" "Fender"}]})
Please refer to the examples in the source to see how templates can be managed using layouts and includes.
Thanks to the authors of jade4j for bringing jade to the JVM.
Copyright © 2013
Distributed under the Eclipse Public License, the same as Clojure.