diff --git a/src/clj_jtwig/core.clj b/src/clj_jtwig/core.clj index c57e9ac..228bd91 100644 --- a/src/clj_jtwig/core.clj +++ b/src/clj_jtwig/core.clj @@ -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 - "I don't do a whole lot." - [x] - (println x "Hello, World!")) +(defn render + "renders a template contained in the provided string, using the values in model-map + as the model for the template." + [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)))