burak
(Burak Kavak)
September 10, 2018, 2:10pm
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), ’ ')}
}
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()
1 Like
burak
(Burak Kavak)
September 11, 2018, 9:34am
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, ’ ')}
}
Great that this works. Please mark it as solved
For anyone interested in this, in Neos 4 you can use Neos.Fusion:Join
with the @glue
option instead of a RawArray
that needs to be joined later on. More details in the documentation .