I have started with the following ninja2 template, but If the value of the 2nd column is > the specified width, it simply prints the entire string and the rest of the columns shift right.
{{ "%-7s"|format(tbl[3]) }}      {{ "%-12s"|format(tbl[5]) }}    {{ "%14s"|format(tbl[6]) }}
The problem I want to solve is how to truncate the second column when (and only when) the tbl[5] value exceeds the column width.
Any ideas. I've googled, but can't find an answer.
Have you tried the truncate function:
{{ "foo bar baz qux"|truncate(9,true,'') }}
Like first parameter is the length the second tells you if you want to truncate exactly at length(if true) or truncate from a complete word. The third is the ellipsis, in this case a I removed the default ... and I put a blank instead.
Let me know if this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With