mirror of
https://gitlab.com/etke.cc/emm.git
synced 2026-03-11 18:30:31 +00:00
29 lines
502 B
Go
29 lines
502 B
Go
package export
|
|
|
|
import (
|
|
"os"
|
|
"text/template"
|
|
)
|
|
|
|
func createTemplate(templatePath string) (*template.Template, error) {
|
|
var err error
|
|
templateContent := DefaultTemplate
|
|
if templatePath != "" {
|
|
templateContent, err = loadTemplate(templatePath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
return template.New("emm").Parse(templateContent)
|
|
}
|
|
|
|
func loadTemplate(path string) (string, error) {
|
|
content, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return string(content), nil
|
|
}
|