Closed lexxpavlov closed 10 years ago
I don't think such operator should go in core. It is very specific and could be hard to understand.
Note that nothing prevents you to define this operator in your own project thanks to a Twig extension.
Indeed; also, this would reserve two different ASCII characters for (essentially) the same operation, which might prevent something down the line from using @ for some other purpose.
Twig is a well sugared language. I think this operator logically fits in the language. And @soatok rightly mentions about two different characters. Maybe use double tilda for this operator. That will be semantically linked with current concat operator.
{% set greet2 = hello ~~ name %}
In my taste, expression ~ ' ' ~
is terrible.
I do agree that it is pretty ugly having to do that, and I also need to do that (ie. First name + last name, zip + address etc ) Not sure about technical issues but just ~~ does seem a but prettier.
I'm also reluctant to add a special operator for this specific use case.
It is often necessary to concat the two strings with a space between them. I propose adding a special operator for this:
I have seen such an operator in UnrealScript, where used @ operator for joining with space, so I brought this operator in the example above.