feat(template): add name to the template definition
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package actions
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"tomatentum.net/svg-templater/internal/database"
|
||||
)
|
||||
|
||||
func RenameSvg(id string, name string) error {
|
||||
err := database.RenameSvg(id, name)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("Changed template %s name to %s.\n", id, name)
|
||||
return nil
|
||||
}
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"tomatentum.net/svg-templater/pkg/svg"
|
||||
)
|
||||
|
||||
func Create(svgbuf []byte) (svg.TemplateData, error) {
|
||||
data := svg.TemplateData{Id: generateId(), TemplateKeys: nil}
|
||||
func Create(svgbuf []byte, name string) (svg.TemplateData, error) {
|
||||
data := svg.TemplateData{Id: generateId(), Name: name, TemplateKeys: nil}
|
||||
populateKeys(&data, svgbuf)
|
||||
|
||||
_, err := svg.Storage.Create(data.Id, bytes.NewReader(svgbuf))
|
||||
|
||||
@@ -4,6 +4,7 @@ const KeyRegex string = `\{\{\s*(.*?)\s*\}\}`
|
||||
|
||||
type TemplateData struct {
|
||||
Id string
|
||||
Name string
|
||||
TemplateKeys []string
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user