-
Notifications
You must be signed in to change notification settings - Fork 42
/
functions.go
64 lines (55 loc) · 1.3 KB
/
functions.go
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
// Copyright 2017 Seamia Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"strings"
"text/template"
"github.com/seamia/tools/support"
)
func oneword(t string) string {
return "oneword(" + t + ")"
}
func title(t string) string {
return "title(" + t + ")"
}
func color(name string) string {
if g_config != nil {
if colors, found := g_config["colors"]; found {
colorMap := colors.(map[string]interface{})
if colorMap != nil {
if maps2, found := colorMap[name]; found {
name = maps2.(string)
}
}
}
}
c, found := support.GetColor(name)
if found != nil {
fmt.Println("failed to resolve color name", name)
}
return c
}
func settings(key string) string {
if g_config != nil {
if colors, found := g_config["settings"]; found {
settingsMap := colors.(map[string]interface{})
if settingsMap != nil {
if value, found := settingsMap[key]; found {
return value.(string)
}
}
}
}
fmt.Println("failed to resolve setting name", key)
return "setting[" + key + "]"
}
// type FuncMap map[string]interface{}
var templFuncs = template.FuncMap{
"lower": strings.ToLower,
"title": title,
"settings": settings,
"color": color,
"oneword": oneword,
}