Home > Software engineering >  String concatenation with Twig
String concatenation with Twig

Time:01-06

This is not a major problem but there is a better way to concatenate a string like this one :

{{ "© " ~ "now"|date("Y") ~ " " ~ site.name ~ " " ~ __( "Tous droits réservés", "NAMEOFMYSITE" ) }}

Especially the blank character between variables.

Thanks all.

CodePudding user response:

You could use an array and the filter join, e.g.

{{ [ '©', "NOW"|date('Y'), site.name ]|join(' ') }}

demo

  •  Tags:  
  • Related