refactor(upload): move Regex to variable
This commit is contained in:
@@ -27,9 +27,9 @@ func Create(svgbuf []byte) (svg.TemplateData, error) {
|
|||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func populateKeys(data *svg.TemplateData, svg []byte) {
|
func populateKeys(data *svg.TemplateData, svgblob []byte) {
|
||||||
regex := regexp.MustCompile(`\{\{\s*(.*?)\s*\}\}`)
|
regex := regexp.MustCompile(svg.KeyRegex)
|
||||||
result := regex.FindAllSubmatch(svg, -1)
|
result := regex.FindAllSubmatch(svgblob, -1)
|
||||||
templateKeys := make([]string, len(result))
|
templateKeys := make([]string, len(result))
|
||||||
|
|
||||||
for i, matches := range result {
|
for i, matches := range result {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package svg
|
package svg
|
||||||
|
|
||||||
|
const KeyRegex string = `\{\{\s*(.*?)\s*\}\}`
|
||||||
|
|
||||||
type TemplateData struct {
|
type TemplateData struct {
|
||||||
Id string
|
Id string
|
||||||
TemplateKeys []string
|
TemplateKeys []string
|
||||||
|
|||||||
Reference in New Issue
Block a user