Skip to content

Commit

Permalink
feat: add a new 'now' template helper
Browse files Browse the repository at this point in the history
Usage examples:

    {{now}}                                             2009-11-10 23:00:00 +0000 UTC m=+0.000000001
    {{now.Unix}}                                        1257894000
    {{now.UnixNano}}                                    1257894000000000000
    {{now.Format `Mon Jan 2 15:04:05 -0700 MST 2006`}}  Tue Nov 10 23:00:00 +0000 UTC 2009

https://play.golang.org/p/Pf5k_P1pP5M
  • Loading branch information
moul authored and muesli committed Apr 28, 2021
1 parent 0efe78e commit bd9e8e8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io/ioutil"
"net/http"
"os"
"time"

"github.com/KyleBanks/goodreads"
"github.com/shurcooL/githubv4"
Expand Down Expand Up @@ -53,6 +54,7 @@ func main() {
/* Utils */
"humanize": humanized,
"reverse": reverse,
"now": time.Now,
}).Parse(string(tplIn))
if err != nil {
fmt.Println("Can't parse template:", err)
Expand Down

0 comments on commit bd9e8e8

Please sign in to comment.