2017-06-17 15:14:15 +02:00

29 lines
587 B
Go

package utils
import (
"io/ioutil"
"strings"
)
var svgIcons = make(map[string]string)
func init() {
files, _ := ioutil.ReadDir("images/icons/")
for _, file := range files {
name := strings.Replace(file.Name(), ".svg", "", 1)
data, _ := ioutil.ReadFile("images/icons/" + name + ".svg")
svgIcons[name] = strings.Replace(string(data), "<svg ", "<svg class='icon' ", 1)
}
}
// Icon ...
func Icon(name string) string {
return svgIcons[name]
}
// RawIcon ...
func RawIcon(name string) string {
return strings.Replace(svgIcons[name], "class='icon'", "class='raw-icon'", 1)
}