TemplateOptions.Now usage
Closed this issue · 4 comments
Hello,
Does TemplateOptions.Now dictate how "now" should work? Tried the following in the code:
var options = new TemplateOptions
{
Now = () => DateTimeOffset.UtcNow,
TimeZone = TimeZoneInfo.FindSystemTimeZoneById("Europe/London")
};
and tried using it like {{ now | add_days: 3 }}
where add_days
is a custom filter which is used to increment the date passed in.
However, when the control went to the filter logic, it is seen that "now" wasn't converted to a date/time format.
It's "now"
not now
. And this won't work with all filters. It's up to you to handle that input in your filter and to call Now
from the options. You can check the source code of thedate
filter as an example.
Thanks @sebastienros, we do specify as "now" (was a typo in the above example). I will check out the filter you have specified.
@sebastienros is it mandatory to call a filter in order to realise the value of 'now'? Would RenderAsync work if we pass in {{ 'now' }} as the template?