Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP 7.4 trimming whitespace between string variables

Tags:

php

twig

timber

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?

like image 825
Luis Martins Avatar asked May 05 '20 09:05

Luis Martins


1 Answers

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).

like image 82
Vladimir Avatar answered Oct 03 '22 06:10

Vladimir