Home > Software design >  How to break line between 2 variables
How to break line between 2 variables

Time:12-08

I'm trying to have something like this:

Rue Félicité Beaudin
13004 Marseille

And in twig I've got 3 variables :

  • user.address
  • user.zipcode
  • user.city

I've tried to do :

{{ company.address~"\n"~company.zipcode|raw|nl2br }} {{ company.city }}

but no success, is there a way to break the line between 2 variables ?

CodePudding user response:

Your filters willy only apply the closest variable met, meaning the filters will only be applied to company.zipcode.

You need to add parentheses to span across multiple elements,

{{ (company.address~"\n"~company.zipcode)|raw|nl2br }}

demo

  • Related