Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to combine two string in twig?

Tags:

twig

I want to do something like this:

{% set c=a+b %} 

Where a and b are strings.
How can I do it?

like image 551
sh3211 Avatar asked May 06 '12 12:05

sh3211


People also ask

How to concatenate two strings in twig?

Combining strings Twig provides two ways to combine strings together: You can concatenate them using the tilde ( ~ ) operator, or you can inject a string into the middle of another string using string interpolation.

What does tilde mean in twig?

Use the tilde character ~ to concatenate string and/or variables. ~: Converts all operands into strings and concatenates them.


1 Answers

The way to do it is:

{% set c = a ~ b %} 
like image 167
Shimon S Avatar answered Oct 06 '22 08:10

Shimon S