-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathconsts_typescript.qtpl
69 lines (47 loc) · 1.56 KB
/
consts_typescript.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
{% import "github.com/delaneyj/toolbelt" %}
{%- func typescriptConsts(data *ConstTemplateData) -%}
// {%s data.DoNotEdit %}
export const DATASTAR = "{%s data.DatastarKey %}" as const;
export const DATASTAR_REQUEST = "{%s toolbelt.Pascal( data.DatastarKey) %}-Request";
export const VERSION = "{%s data.Version %}";
// #region Defaults
// #region Default durations
{%- for _, d := range data.DefaultDurations -%}
// {%s= d.Description %}
export const Default{%s d.Name.Pascal %}Ms = {%d durationToMs(d.Duration) %};
{%- endfor -%}
// #endregion
// #region Default strings
{%- for _, s := range data.DefaultStrings -%}
// {%s= s.Description %}
export const Default{%s s.Name.Pascal %} = "{%s s.Value %}";
{%- endfor -%}
// #endregion
// #region Default booleans
{%- for _, b := range data.DefaultBools -%}
// {%s= b.Description %}
export const Default{%s b.Name.Pascal %} = {%v b.Value %};
{%- endfor -%}
// #endregion
// #region Datalines
{%- for _, literal := range data.DatalineLiterals -%}
export const DatastarDataline{%s literal.Pascal %} = "{%s literal.Camel %}"
{%- endfor -%}
// #endregion
// #region Enums
{%- for _, enum := range data.Enums -%}
// {%s= enum.Description %}
export const {%s enum.Name.Pascal %}s = [
{%- for _, entry := range enum.Values -%}
// {%s= entry.Description %}
"{%s entry.Value %}",
{%- endfor -%}
] as const;
{%- if enum.Default != nil -%}
// Default value for {%s enum.Name.Pascal %}
export const Default{%s enum.Name.Pascal %} = "{%s enum.Default.Value %}";
{%- endif -%}
{%- endfor -%}
// #endregion
// #endregion
{%- endfunc -%}