1

How can I create a variable that is a combination of two variables with text?

For example, I know the following is wrong but is something like this possible:

{% set foo = 'foo' %}
{% set bar = 'bar' %}
{% set foobar = 'Hello' foo,bar %}
{{ foobar }} #Outputs Hello foobar

1 Answer 1

2

You can concatenate variables like this:

{% set foo = 'foo' %}
{% set bar = 'bar' %}
{% set foobar = 'Hello' ~ foo ~ bar %}
{{ foobar }} #Outputs Hello foobar

It's explained by Brandon here.

1
  • Perfect thanks! Thank you for the resource too, very helpful!
    – JRW
    Oct 12, 2015 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.