split up core compiled template generation & rendering
This commit is contained in:
parent
36a8e3f113
commit
e497323ca2
|
@ -22,10 +22,13 @@
|
||||||
(stringify-keys context)
|
(stringify-keys context)
|
||||||
{}))
|
{}))
|
||||||
|
|
||||||
(defn render [^String template-source & [context]]
|
(defn- render-template [^String template context]
|
||||||
(.setLoader @engine string-loader)
|
(if-let [^PebbleTemplate compiled-template (.getTemplate @engine template)]
|
||||||
(if-let [^PebbleTemplate compiled-template (.getTemplate @engine template-source)]
|
|
||||||
(let [writer (StringWriter.)
|
(let [writer (StringWriter.)
|
||||||
context (prepare-context-map context)]
|
context (prepare-context-map context)]
|
||||||
(.evaluate compiled-template writer context)
|
(.evaluate compiled-template writer context)
|
||||||
(.toString writer))))
|
(.toString writer))))
|
||||||
|
|
||||||
|
(defn render [^String template-source & [context]]
|
||||||
|
(.setLoader @engine string-loader)
|
||||||
|
(render-template template-source context))
|
||||||
|
|
Loading…
Reference in a new issue