add simple render function

This commit is contained in:
Gered 2014-03-01 10:32:21 -05:00
parent 45c4417e41
commit abc0d93722

View file

@ -1,6 +1,15 @@
(ns clj-jtwig.core) (ns clj-jtwig.core
(:require [clojure.walk :refer [stringify-keys]])
(:import (com.lyncode.jtwig JtwigTemplate JtwigContext)))
(defn foo (defn render
"I don't do a whole lot." "renders a template contained in the provided string, using the values in model-map
[x] as the model for the template."
(println x "Hello, World!")) [s model-map & [{:keys [skip-model-map-stringify?] :as options}]]
(let [template (new JtwigTemplate s)
context (new JtwigContext)]
(doseq [[k v] (if-not skip-model-map-stringify?
(stringify-keys model-map)
model-map)]
(.set context k v))
(.output template context)))