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

Merged
merged 1 commit into from Jan 1, 2017

Conversation

Projects
None yet
4 participants
@nishanths
Contributor

nishanths commented Dec 31, 2016

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.

<link rel="stylesheet" href="/css/reset.css?t={{ timeNow.Unix }}">

I'm sure hugo users will come up with other creative uses for current time.

@CLAassistant

This comment has been minimized.

Show comment
Hide comment
@CLAassistant

CLAassistant Dec 31, 2016

CLA assistant check
All committers have signed the CLA.

CLAassistant commented Dec 31, 2016

CLA assistant check
All committers have signed the CLA.

@nishanths nishanths changed the title from tpl: add timeNowUTC to tpl: add timeNow Dec 31, 2016

@moorereason

This comment has been minimized.

Show comment
Hide comment
@moorereason

moorereason Dec 31, 2016

Contributor

time.Now is already accessible on the Page object.

However, I've started a discussion referencing this PR: https://discuss.gohugo.io/t/4968

Contributor

moorereason commented Dec 31, 2016

time.Now is already accessible on the Page object.

However, I've started a discussion referencing this PR: https://discuss.gohugo.io/t/4968

@nishanths nishanths changed the title from tpl: add timeNow to tpl: add now function Dec 31, 2016

@nishanths

This comment has been minimized.

Show comment
Hide comment
@nishanths

nishanths Dec 31, 2016

Contributor

Updated the function name to now

Contributor

nishanths commented Dec 31, 2016

Updated the function name to now

Show outdated Hide outdated tpl/template_funcs.go
tpl: add now function
Add a now template function that returns the current time as time.Time.
Also, update related docs.

@bep bep merged commit cabc6b3 into gohugoio:master Jan 1, 2017

4 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/wercker Wercker build passed
Details
licence/cla Contributor License Agreement is signed.
Details

@nishanths nishanths deleted the nishanths:time-now-utc branch Jan 1, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment