-
Notifications
You must be signed in to change notification settings - Fork 12k
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
TemplateSrv: Formatting options for ${__from} and ${__to}, unix seconds epoch, ISO 8601/RFC 3339 #26466
Conversation
a new templating syntax! 🤯 When I actually look at the code, it looks great -- totally reasonable. I just get scared by adding more powerful hidden complex features to templateSrv. +1 to refactor the formats into a Registry that we can more clearly promote with IntelliSense etc. |
There is similar need for "to" like ${__to:date:ms}, see #18763 |
of course, this also handled ${__to} |
Ok, ready for merge. Updated docs. The refactor to registry will come in new PR as we need to cherry-pick this to 7.1.2 so want to keep this PR as small as possible, so moving the refactoring to a new PR. |
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.
Good to go aside from some grammar suggestions in the docs.
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
…ds epoch, ISO 8601/RFC 3339 (#26466) * TemplateSrv: WIP date formats * Templating: formats with arguments * WIP docs updates * Docs: Updated docs * fixed spelling * Update docs/sources/variables/global-variables.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/variables/global-variables.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/variables/global-variables.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/variables/global-variables.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> (cherry picked from commit 6c49fdb)
…ds epoch, ISO 8601/RFC 3339 (#26466) * TemplateSrv: WIP date formats * Templating: formats with arguments * WIP docs updates * Docs: Updated docs * fixed spelling * Update docs/sources/variables/global-variables.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/variables/global-variables.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/variables/global-variables.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/variables/global-variables.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> (cherry picked from commit 6c49fdb)
Closes #15903
Introduces an extended templating syntax format that can have 1 or more arguments like this
${variable:<formatName>:<optionalArg1>:<optionalArg2>}
Adds date format and args
${__from:date}
no args, defaults to iso/rfc (example 2020-07-13T20:19:09.254Z)${__from:date:iso}
same as above${__from:date:ms}
unix millisecond epoch same as no date format${__from}
${__from:date:seconds}
unix seconds epoch${__from:date:YYYY-MM}
custom date formatTODO
In the upcoming PR: