From 746cce94f0dc6bebba8e66526e1e13889e9e5852 Mon Sep 17 00:00:00 2001 From: gered Date: Sat, 1 Mar 2014 16:13:01 -0500 Subject: [PATCH] pass in our JTwig functions repo object in to all new context objects --- src/clj_jtwig/core.clj | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/clj_jtwig/core.clj b/src/clj_jtwig/core.clj index e317db3..7f71f7c 100644 --- a/src/clj_jtwig/core.clj +++ b/src/clj_jtwig/core.clj @@ -1,7 +1,7 @@ (ns clj-jtwig.core (:require [clojure.walk :refer [stringify-keys]] [clojure.java.io :as io]) - (:import (com.lyncode.jtwig JtwigTemplate JtwigContext) + (:import (com.lyncode.jtwig JtwigTemplate JtwigContext JtwigModelMap) (com.lyncode.jtwig.functions.exceptions FunctionNotFoundException) (com.lyncode.jtwig.functions.repository DefaultFunctionRepository) (com.lyncode.jtwig.functions JtwigFunction) @@ -34,9 +34,12 @@ (.getContextClassLoader) (.getResource filename))) +(defn- make-context [] + (new JtwigContext (new JtwigModelMap) @functions)) + (defn- render-template [template model-map & [{:keys [skip-model-map-stringify?] :as options}]] - (let [context (new JtwigContext)] + (let [context (make-context)] (doseq [[k v] (if-not skip-model-map-stringify? (stringify-keys model-map) model-map)]