I’m trying to include a Twig template inside another, but there is undesirable whitespace which is caused by the trailing newline in the included template.
My use case is that the include takes place mid-sentence, just before a comma, and I don’t want any whitespace before the comma.
Base template:
Né le {{ include("date.html.twig", {date: date}) }}, décédé le…
Included template:
<time datetime="...">
{{- date.format() -}}
</time>
Desired result :
Né le 6 mai 1977, décédé le…
Actual result :
Né le 6 mai 1977 , décédé le…
I can confirm the trailing newline is the cause of the issue, but removing it is not a viable solution to me since most tools are configured to add it if it’s missing.
Is there any way to trim this trailing newline?