diff --git a/install.go b/install.go index 989a004..c16fd04 100644 --- a/install.go +++ b/install.go @@ -133,7 +133,7 @@ func install(app *App, qMap goyesql.Queries) { // Default template. tplBody, err := ioutil.ReadFile("default-template.html") if err != nil { - tplBody = []byte(`{{ template "content" . }}`) + tplBody = []byte(tplTag) } var tplID int diff --git a/templates.go b/templates.go index 9eae4b1..15c4b61 100644 --- a/templates.go +++ b/templates.go @@ -14,15 +14,20 @@ import ( "github.com/labstack/echo" ) -const dummyTpl = ` +const ( + // tplTag is the template tag that should be present in a template + // as the placeholder for campaign bodies. + tplTag = `{{ template "content" . }}` + + dummyTpl = `
Hi there
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis et elit ac elit sollicitudin condimentum non a magna. Sed tempor mauris in facilisis vehicula. Aenean nisl urna, accumsan ac tincidunt vitae, interdum cursus massa. Interdum et malesuada fames ac ante ipsum primis in faucibus. Aliquam varius turpis et turpis lacinia placerat. Aenean id ligula a orci lacinia blandit at eu felis. Phasellus vel lobortis lacus. Suspendisse leo elit, luctus sed erat ut, venenatis fermentum ipsum. Donec bibendum neque quis.
Nam luctus dui non placerat mattis. Morbi non accumsan orci, vel interdum urna. Duis faucibus id nunc ut euismod. Curabitur et eros id erat feugiat fringilla in eget neque. Aliquam accumsan cursus eros sed faucibus.
-Here is a link to listmonk.
-` +Here is a link to listmonk.
` +) type dummyMessage struct { UnsubscribeURL string @@ -222,8 +227,8 @@ func validateTemplate(o models.Template) error { return errors.New("invalid length for `name`") } - if !strings.Contains(o.Body, `{{ template "content" . }}`) { - return errors.New(`template body should contain the {{ template "content" . }} placeholder`) + if !strings.Contains(o.Body, tplTag) { + return fmt.Errorf("template body should contain the %s placeholder", tplTag) } return nil