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:
parent
39b03cc393
commit
29c5d82016
3 changed files with 12 additions and 4 deletions
|
@ -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)
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue