mirror of
https://github.com/knadh/listmonk.git
synced 2025-09-07 15:05:37 +08:00
Fix quotes issue in TrackLink
regexp.
This commit is contained in:
parent
70fe7cba6f
commit
dc466fc76b
1 changed files with 4 additions and 3 deletions
|
@ -98,11 +98,11 @@ type regTplFunc struct {
|
|||
|
||||
var regTplFuncs = []regTplFunc{
|
||||
// Regular expression for matching {{ TrackLink "http://link.com" }} in the template
|
||||
// and substituting it with {{ Track "http://link.com" . }} (the dot context)
|
||||
// and substituting it with {{ TrackLink "http://link.com" . }} (the dot context)
|
||||
// before compilation. This is to make linking easier for users.
|
||||
{
|
||||
regExp: regexp.MustCompile(`{{(\s+)?TrackLink(\s+)?(.+?)(\s+)?}}`),
|
||||
replace: `{{ TrackLink $3 . }}`,
|
||||
regExp: regexp.MustCompile(`{{\s*TrackLink\s+"([^"]+)"\s*}}`),
|
||||
replace: `{{ TrackLink "$1" . }}`,
|
||||
},
|
||||
|
||||
// Convert the shorthand https://google.com@TrackLink to {{ TrackLink ... }}.
|
||||
|
@ -543,6 +543,7 @@ func (c *Campaign) CompileTemplate(f template.FuncMap) error {
|
|||
for _, r := range regTplFuncs {
|
||||
body = r.regExp.ReplaceAllString(body, r.replace)
|
||||
}
|
||||
|
||||
baseTPL, err := template.New(BaseTpl).Funcs(f).Parse(body)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error compiling base template: %v", err)
|
||||
|
|
Loading…
Add table
Reference in a new issue