Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to join string Volt

Hi all

I have a problem

{% for tag in object.tag%}
    {% set value = tag.name %}
{% endfor %}

I want to variable value is name1, name2, name3...

Volt have support it

Would something like this work?

{% set value = tag.name1 ~ " " ~ tag.name2 %}

Do you want concatenate tag.name values?

To concatenate two string you can use:

{% set value = "this is " ~ "concatenated string." %}

To join tags with commas you can use join:

{% set tags = object.tag|join(', ') %}


34.6k

The first that is ok

The second error

Warning: join(): Invalid arguments passed in /home


3.6k
Accepted
answer

Hmm, maybe object.tag is not array?

I tested this code and works:

{% set tags = ['a','b','c', 'd'] %}
{{ tags|join(', ') }}

The output is a, b, c, d



34.6k

that right