#Handlebars Function
1 messages · Page 1 of 1 (latest)
Hi @glad sundial, I'm an AI assistant for Novu. While a team member reviews this question, I'll look through relevant sources and see if I can provide suggestions. Please tag @worn niche with any follow-up questions.
While I generate an answer, here are some sources that might be helpful:
Answer
Yes, it's possible to add the current date within the template using Handlebars with Novu. You can use the dateFormat handlebar helper function provided by Novu to format the date. For example, to display the current year, you can use the following syntax:
{{dateFormat now 'YYYY'}}
This will render the current year in your template. Ensure that you pass the current date to the template in the appropriate variable (in this case, now) when triggering the notification.
Refer to the Novu documentation for more details on handlebars and helpers (1) .
Sources
[1] Handlebars & Helpers
is this possible without an variable?
@worn niche is this possible without an variable?
Thanks for the follow-up, @glad sundial. I'll get back to you soon.
While I generate an answer, here are some sources that might be helpful:
Answer
Sorry, I wasn't able to find any information about your question.
Got it. Tagging <@&986960430528331776> for additional help.
Hey @glad sundial when you say without variable, you mean without passing this in the payload? or without the handlebars variable syntax?
@barren tiger we want to achieve this without passing payload from the trigger.
the use case is to have a self-updated year within a copyright text.
@glad sundial got it, thanks! I did some testing myself, I cant see it available right now, so you'd have to pass your own as it stand right now. A couple of solutions I can think of, 1 is to add a new handlebars helper, another one is Echo, @glad sundial did you check out https://docs.novu.co/echo/quickstart#introduction-to-echo ?
@quaint river @velvet gorgeam I wrong and we can generate year without payload? cc @long skiff
@barren tiger Yeah, I know eacho, but we are currently not using it.
Would it be an option to add a handlebars helper globally for all?
I think this could be a common use-case
maybe such use-cases can be generally be handled with global variable context, which can be accesed syste wide within all templates
@glad sundial I think if anything, I would allow to access this as a global variable as you mentioned, @velvet gorge @long skiff @quaint river please take a look at let us know what do you think
I think broadly a global context will be the best way to go, but will require more effort. For now easier will be to add a dedicated handlebars helper.
As Tomer mentioned this can be easily achieved with Echo.
For the handlebars helper, i don’t have any estimates, but feel free to submit a PR 🙏
@glad sundial
Added a github issue for this
https://github.com/novuhq/novu/issues/5376