How to Render Human Readable Time in Jinja?

From a UX perspective, human-readable (or humanized) time is a must-have. “5 hours ago,” instead of “22th Dec, 2018 09:18:18 AM” is so much easier to parse. To render timestamps in that format inside a Jinja template, we can create a filter in the flask application code.


How to Uppercase the First Letter in Jinja?

I have been using Jinja for my side-project and was surprised to find that there’s no way to uppercase only the first letter. There is a capitalize filter but it also lowercases the rest of the letters—something you wouldn’t want if your text has acronyms or proper nouns. Jinja doesn’t support sentence case by default, but thankfully it’s not hard to recreate that.