add shared jtwig function repository object
This commit is contained in:
parent
9cd705f858
commit
a124170760
|
@ -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)
|
||||
|
|
Reference in a new issue