How to append a slice to a previously created one?

Pretty straightforward I guess. Having a slice:

{{ $breadcrumb := (slice (dict ... )) }}

How can I, inside a range append a new slice to this one, initialized outside of the loop?

I’ve found a question on Stack Overflow saying what I would be looking for is a built-in function append, but using it reports (another) error saying this function is not defined.

I’m not 100% clear on your exact use case, but to add values within a loop, look at the scratch function:

1 Like