Thanks for the reply @texnixe. My end goal is to be able to iterate over and print the modules created using ‘Kirby Modules’ and pass them variables that are defined in page/site controllers.
As the modules exist as snippets, I thought I may be able to pass the variables in a similar way.
I ended up iterating over the modules then passing the variables.
<?php
$modules = $page->modules();
// Iterate over the modules
foreach ($modules as $module): ?>
<?php
$template = $module->intendedTemplate();
// Remove the first occurrence of 'module.' text that is placed in front of the template name
$template = preg_replace('/\bmodule.\b/', '', $template, 1);
// Call the correct module and variables to the snippet
snippet('modules/' . $template, compact('module', 'example', 'variables')) ?>
<?php endforeach ?>