1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-21 18:11:09 +00:00

Add template helper isEmail()

This commit is contained in:
Frédéric Guillot 2017-11-25 17:08:04 -08:00
parent 39b03cc393
commit 29c5d82016
3 changed files with 12 additions and 4 deletions

View file

@ -9,6 +9,7 @@ import (
"html/template"
"io"
"log"
"net/mail"
"net/url"
"strings"
"time"
@ -64,6 +65,13 @@ func (e *Engine) parseAll() {
return parsedURL.Host
},
"isEmail": func(str string) bool {
_, err := mail.ParseAddress(str)
if err != nil {
return false
}
return true
},
"hasPrefix": func(str, prefix string) bool {
return strings.HasPrefix(str, prefix)
},