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:

[https://my.cdn.com/ t_480_x1/ image_name .jpg]

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

https://my.cdn.com/t_480_x1/image_name.jpg

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

You can use delimit.

3 Likes

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

then {{- $url -}} returns:

https://my.cdn.com/t_480_x1/image_name.jpg

Thanks @pointyfar!

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