-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathconsts_clojure.qtpl
77 lines (58 loc) · 2.29 KB
/
consts_clojure.qtpl
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{%- func clojureConsts(data *ConstTemplateData) -%}
;; {%s data.DoNotEdit %}
(ns starfederation.datastar.clojure.consts
(:require
[clojure.string :as string]))
(def datastar-key "{%s data.DatastarKey %}")
(def version "{%s data.Version %}")
;; -----------------------------------------------------------------------------
;; Default durations
;; -----------------------------------------------------------------------------
{%- for _, d := range data.DefaultDurations -%}
(def default-{%s d.Name.Kebab %}
"{%s= d.Description %}"
{%d durationToMs(d.Duration) %})
{%- endfor -%}
;; -----------------------------------------------------------------------------
;; Default values
;; -----------------------------------------------------------------------------
{%- for _, s := range data.DefaultStrings -%}
(def default-{%s s.Name.Kebab %}
"{%s= s.Description %}"
(-> "{%s s.Value %}"
(string/split #" ")
(update 0 keyword)
(->> (apply array-map))))
{%- endfor -%}
;; -----------------------------------------------------------------------------
;; Dataline literals
;; -----------------------------------------------------------------------------
{%- for _, literal := range data.DatalineLiterals -%}
(def {%s literal.Kebab %}-dataline-literal "{%s literal.Camel %} ")
{%- endfor -%}
;; -----------------------------------------------------------------------------
;; Default booleans
;; -----------------------------------------------------------------------------
{%- for _, b := range data.DefaultBools -%}
(def default-{%s b.Name.Kebab %}
"{%s= b.Description %}"
{%v b.Value %})
{%- endfor -%}
;; -----------------------------------------------------------------------------
;; Enums
;; -----------------------------------------------------------------------------
{%- for _, enum := range data.Enums -%}
;; {%s enum.Name.Pascal %}
{%- for _, entry := range enum.Values -%}
(def {%s enum.Name.Kebab %}-{%s entry.Name.Kebab %}
"{%s= entry.Description %}"
"{%s entry.Value %}")
{%- endfor -%}
{%- if enum.Default != nil -%}
(def default-{%s enum.Name.Kebab %}
"Default value for {%s enum.Name.Pascal %}.
{%s= enum.Default.Description %}"
{%s enum.Name.Kebab %}-{%s enum.Default.Name.Kebab %})
{%- endif -%}
{%- endfor -%}
{%- endfunc -%}