From feefe82a30d58ee35cfcd05a9db01abf9033ec69 Mon Sep 17 00:00:00 2001 From: gered Date: Sun, 2 Mar 2014 12:47:49 -0500 Subject: [PATCH] add get-compiled-template function eventually this will handle fetching pre-compiled templates out of the cache, but for now this will help us refactor everything else to use this instead and work with compiled template objects instead elsewhere --- src/clj_jtwig/core.clj | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/clj_jtwig/core.clj b/src/clj_jtwig/core.clj index e5a099d..ca3c2bb 100644 --- a/src/clj_jtwig/core.clj +++ b/src/clj_jtwig/core.clj @@ -13,6 +13,13 @@ ; be rendered by calling it's 'render' method (defonce compiled-templates (atom {})) +(defn- get-compiled-template [file] + (if-not (.exists file) + (throw (new FileNotFoundException (str "Template file \"" file "\" not found."))) + (->> file + (new JtwigTemplate) + (.compile)))) + (defn- create-function-repository [] (new DefaultFunctionRepository (make-array JtwigFunction 0)))