Convert all values of an array into a single string

I am building an image reference to an external CDN url via shortcode. I have most of it assembled and its working for the most part. The last piece of the puzzle is to take the output in the form of an array and convert the entire thing to a string…

How can I take an array that looks like this:

[ t_480_x1/ image_name .jpg]

and flatten it to a string so I can pass it into my shortcode like this:

Its late and I’ve been chasing this around for a couple hours and feel like I’m missing something obvious.

You can use delimit.


That did the trick! I knew it was something simple and obvious. For the sake of completion here is the adjusted code:
{{ $myURL := ( slice $cdn $id $etc $fileExtension ) }}
{{ $url := delimit $myURL "" }}

then {{- $url -}} returns:

Thanks @pointyfar!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.