New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tpl: add now function #2859
tpl: add now function #2859
Conversation
However, I've started a discussion referencing this PR: https://discuss.gohugo.io/t/4968 |
Updated the function name to |
@@ -2186,6 +2186,7 @@ func initFuncMap() { | |||
"substr": substr, | |||
"title": title, | |||
"time": asTime, | |||
"now": func() time.Time { return time.Now() }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this fits fine next to time, but the rest of them are alphabetic ordered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thanks
Add a now template function that returns the current time as time.Time. Also, update related docs.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Add a timeNow template function that returns the current time as
time.Time. Also, update related docs.
Don't know what the right way to test this change is (if necessary), so I'm open to suggestions.
Personally, I'm looking to use use the unix timestamp of the current time in the query string for cache busting in a theme.
I'm sure hugo users will come up with other creative uses for current time.