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
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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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