truncate
is indeed a simplification.
For example the above technique can be condensed into:
{{ $caption := .Site.Params.caption | truncate 145 }}{{ $caption }}{{ end }}
However, truncate
does not suit my needs.
truncate
outputs: blahablah ...
meanwhile the technique with split
above outputs: blahablah...
The space that is rendered between the last word and the ellipsis with truncate
is undesirable for me
(I am aware that one could use regEx to eliminate that space, but that is a bit of an overkill).
It’s all a matter of style preference.