Hola! ¡Tenemos nuestra Comunidad en Español!

How do I concatenate strings with HUBL?

Occasional Contributor

How can I concatenate strings with Hubl? The docs suggest there is a special operator for it (~), however I have tried to use it in many different ways and I can't preduce the behaviour I expect.


I need to loop through an list and build up a string with the contents of the list. I have tried this and after the loop the 'items' variable has no value...


{% set items = "" %}

{% for row in hubdb_table_rows(1034058, "orderBy=random()") %}
{{ items = items ~ ("Test"+loop.index0+", ") }}
{% endfor %}
<div>{{ items }}</div>


Has anyone managed to do this before?

3 Replies 3
Esteemed Contributor | Platinum Partner


{% set items = [] %}
{% for x in array %}
       {% set _dummyvar = items.append(x) %}
{%endfor %}


This wont get you 100% of the way but will get you most of the way. Wasn't entirely sure I understood what you were intending to do.

Messages posted by this account have been preserved for their historical usefulness. Jon has a new profile now.

@BillOddie you'll want to use the tilde in the statement rather than the expression. For example:

{% set items = "string 1" ~ "string 2" %}

Hope that helps!

Stefen Phelps
Web Developer / Co-founder
Kelp Creative Agency
Twitter — @stefen
Occasional Contributor



Thank you both for your answers.


I ended up using join| filter to print the list as a string with a custom delimiter. 


Sorry if my question was confusing