Darkle there's no proper way, but there are multiple solutions.
I don't think <script>
tags in an HTML page will execute, but you can use other methods to run javascript from HTML, like an image onload
or onerror
callback.
If you are able to compile your javascript as an extension, there are more solutions. Extend the global page and look at the path. Or create a custom component then embed it in the custom page using the mithrilComponent
extender of the extension.
I have not tested this, but you might be able to define an anonymous component inline using the extender, something like:
return [
(new \ClarkWinkelmann\PagesGenerator\Pages())
->source(__DIR__ . '/pages')
->mithrilComponent('RunMyCode', "{view(){return null;},oncreate(){/* arbitrary code */}}"),
];
And then adding <RunMyCode>
in the custom page.
In the future I plan to make the custom page component extendable to add custom behavior. And I could make <script>
tags work on HTML pages if that makes sense.