add shared jtwig function repository object

This commit is contained in:
Gered 2014-03-01 15:36:28 -05:00
parent 9cd705f858
commit a124170760

View file

@ -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)