From a124170760eb2567d01e02d6ba5e87cb51313f52 Mon Sep 17 00:00:00 2001 From: gered Date: Sat, 1 Mar 2014 15:36:28 -0500 Subject: [PATCH] add shared jtwig function repository object --- src/clj_jtwig/core.clj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/clj_jtwig/core.clj b/src/clj_jtwig/core.clj index fed463a..937c6ad 100644 --- a/src/clj_jtwig/core.clj +++ b/src/clj_jtwig/core.clj @@ -2,8 +2,14 @@ (:require [clojure.walk :refer [stringify-keys]] [clojure.java.io :as io]) (:import (com.lyncode.jtwig JtwigTemplate JtwigContext) + (com.lyncode.jtwig.functions.repository DefaultFunctionRepository) + (com.lyncode.jtwig.functions JtwigFunction) (java.io File FileNotFoundException))) +; we'll be reusing the same function repository object for all contexts created when rendering templates. +; any custom functions added will be added to this instance +(defonce functions (atom (new DefaultFunctionRepository (make-array JtwigFunction 0)))) + (defn- get-resource-path [filename] (-> (Thread/currentThread) (.getContextClassLoader)