move jtwig context related option handling to make-context

This commit is contained in:
Gered 2014-03-01 16:48:18 -05:00
parent 7bb21bbeef
commit b892b82221

View file

@ -37,17 +37,17 @@
(.getContextClassLoader) (.getContextClassLoader)
(.getResource filename))) (.getResource filename)))
(defn- make-context [] (defn- make-context [model-map {:keys [skip-model-map-stringify?] :as options}]
(new JtwigContext (new JtwigModelMap) @functions)) (let [context (new JtwigContext (new JtwigModelMap) @functions)]
(defn- render-template
[template model-map & [{:keys [skip-model-map-stringify?] :as options}]]
(let [context (make-context)]
(doseq [[k v] (if-not skip-model-map-stringify? (doseq [[k v] (if-not skip-model-map-stringify?
(stringify-keys model-map) (stringify-keys model-map)
model-map)] model-map)]
(.set context k v)) (.set context k v))
(.output template context))) context))
(defn- render-template
[template model-map & [options]]
(.output template (make-context model-map options)))
(defn render (defn render
"renders a template contained in the provided string, using the values in model-map "renders a template contained in the provided string, using the values in model-map