-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.clj
33 lines (27 loc) · 1.01 KB
/
core.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(ns derivative.templating.core
(:require
[hbs.core :as templates]
[hbs.helper :as template-helpers]
[derivative.templating.helpers :as template-helper-fns]))
(defn registry [& {:as helpers}]
(reduce
(fn [registry [name helper]]
(template-helpers/register-helper! registry name helper))
(templates/registry (templates/classpath-loader))
helpers))
(def ^:dynamic *registry*
(registry
"snake_case" template-helper-fns/snake-case
"camel_case" template-helper-fns/camel-case
"upper_camel_case" template-helper-fns/upper-camel-case
"kebab_case" template-helper-fns/kebab-case
"upper_case" template-helper-fns/upper-case
"lower_case" template-helper-fns/lower-case
"increment" template-helper-fns/increment
"decrement" template-helper-fns/decrement
"random_password" template-helper-fns/random-password))
(defn render
([template context]
(render *registry* template context))
([registry template context]
(templates/render registry template context)))