Refactor TrackLink template function to accept backticks

Quill link dialog (righly) escapes quotes in URL values there by breaking the
TrackLink() template function. That is, {{ TrackLink "https://listmonk.app" }}
when inserted using the Quill link dialog would become
{{ TrackLink "https://listmonk.app" }}. A simplework around is to
add support to backticks so that the template parser works with
{{ TrackLink `https://listmonk.app` }}
This commit is contained in:
Kailash Nadh 2018-12-19 12:28:52 +05:30
parent ffd43cec6c
commit 1fd3a3bada
2 changed files with 2 additions and 3 deletions

View File

@ -223,7 +223,6 @@ func (m *Manager) Run(tick time.Duration) {
m.sendNotif(newC, newC.Status, "")
}
}
}
// SpawnWorkers spawns workers goroutines that push out messages.

View File

@ -51,8 +51,8 @@ const (
// and substituting it with {{ Track "http://link.com" .Campaign.UUID .Subscriber.UUID }}
// before compilation. This string gimmick is to make linking easier for users.
var (
regexpLinkTag = regexp.MustCompile(`{{(\s+)?TrackLink\s+?"(.+?)"(\s+)?}}`)
regexpLinkTagReplace = `{{ TrackLink "$2" .Campaign.UUID .Subscriber.UUID }}`
regexpLinkTag = regexp.MustCompile("{{(\\s+)?TrackLink\\s+?(\"|`)(.+?)(\"|`)(\\s+)?}}")
regexpLinkTagReplace = `{{ TrackLink "$3" .Campaign.UUID .Subscriber.UUID }}`
regexpViewTag = regexp.MustCompile(`{{(\s+)?TrackView(\s+)?}}`)
regexpViewTagReplace = `{{ TrackView .Campaign.UUID .Subscriber.UUID }}`