My approach to this is to use truncate, as it is the only portable option that I have found that also works with lower. `{{ "HelloWorld" | lower | truncate(5, True, '') == "hello" }}`.
truncate
lower