Search code examples
symfonytwig

How to break line between 2 variables


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 ?


Solution

  • 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