Search code examples
phptwigtimber

PHP 7.4 trimming whitespace between string variables


I'm running into an issue where when I have multiple variables being output into a class attribute, they all get compressed into a single word rather than kept as separate words as originally authored, as in

<div class="className {{ variable1 }} {{ variable2 }}"><div>

At runtime this is being rendered as:

<div class="className variable1variable2"><div>

Any idea what would cause this and how to avoid it?


Solution

  • Faced the same issue on PHP 7.4. Found this fix on GitHub.

    So if you're using Twig 1, upgrade it at least to v1.43.0.

    If you're using Twig 2, upgrade it at least to v2.10.0. (my case - I had v2.7.4 in the project).