Apply example in docs

In the docs for apply:

The following example is given:

names: [ "Derek Perkins", "Joe Bergevin", "Tanner Linsley" ]

You can then use apply as follows:

{{ apply .Params.names "urlize" "." }}

Which will result in the following:

"derek-perkins", "joe-bergevin", "tanner-linsley"

But the result I get is:

[derek-perkins joe-bergevin tanner-linsley]

Is this an error on my part?

I’m surprised this worked for you. Since it’s TOML front matter, it should be names = not names:

But yes the result you get is expected. You can debug it like so:

{{ $output := apply .Params.names "urlize" "." }}
{{ $output }}

{{ printf "%#v" $output | safeHTML }}

Which will give:

[derek-perkins joe-bergevin tanner-linsley]

[]interface {}{"derek-perkins", "joe-bergevin", "tanner-linsley"}

Thanks. An error on my part regarding the TOML front matter in my post.

Just so I understand, if I would like each name to be comma separated and urlized, I would need to use a range with delimit instead of apply. Is that correct?

If you scroll further down in that apply doc, they give you the delimit example that you want

1 Like

Understood. Saw it earlier, just wanted to check with the apply statement. Many thanks as always for helping out.