Kirby Modules: pass data

How would you use the below function? In which format do you put data inside data = []?

$page->modules($data = [], $return = false);

I tried $data = $collection and $data = [$collection] and it seems not be working.

In my case I need to number each module and need to pass on the collection to the snippet that builds each module.

Thanks!

Use it like this:

$page->modules([
  'collection' => $collection,
]);

you can then use the $collection variable in your template.

D’oh, perfect! Thank you.