Neos.Fusion:Array : String with separators


(Burak Kavak) #1

I want to get a String representation of a Fusion array with a self defined separator. Let’s say I have this Fusion Array:

test = Neos.Fusion:Array {
o1 = ‘test1’
o2 = ‘test2’
o3 = ‘test3’
}

Printing this Array in the fluid template gives me “test1test2test3”, but what I want is “test1 test2 test3”. How would I do this in Fusion?

The functionality that Array.join(array, separator) provides doesn’t work for me, using this code:

output = Neos.Fusion:Value {
value = ${Array.join(q(test), ’ ')}
}


(Daniel Lienert) #2

Hey,

Unfortunately that is confusing. Neos.Fusion:Array returns a concatenated string when evaluated. So the joining is already done.

What you need is Neos.Fusion:RawArray which is evaluated to an array which you then can concatenate yourself with a separator using Array.join()


(Burak Kavak) #3

Thanks for the quick answer. This works:

@context.test = Neos.Fusion:RawArray {
o1 = ‘test1’
o2 = ‘test2’
o3 = ‘test3’
}

output = Neos.Fusion:Value {
value = ${Array.join(test, ’ ')}
}