Is there a way to dynamically generate the JavaScript that's to be loaded for a page (e.g. the script uses the current page's title) yet use ResourceLoader? Right now I'm using:
$output = RequestContext::getMain()->getOutput();
$output->addModules('ext.JSRun');
and ext.JSRun is defined in extension.json ResourceModules to be a "script.js" in the extension directory. Problem is, it's going to load the same script every time without a way to customize it using PHP for every page.
I could use the makeInlineScript function in ResourceLoader, but inline scripts aren't recommended. Is there a better way to approach the problem?