<div dir="ltr"><div><div>Hello,<br><br></div>In my quest to port an app to Dancer2, I stumbled with problems in Dancer2::Plugin. The issues arise because plugins don&#39;t really have access to the app (hooks, in particular) that is using them except when they are being imported.<br>
<br></div><div>I put together a Dancer2::Plugin substitute that basically declares hooks and keywords while the plugin is being imported into a calling app, using its dsl. It also creates a plugin object to hold its registered keywords, hooks it provides and any hooks that the plugin needs to have run externally (like during template rendering). Without singletons.<br>
<br></div><div>This Dancer2::Plugin does not pass all the tests. It fails when plugins try to do &quot;dancer things&quot; outside of hooks and registered words, because there is no dsl to support them. Some test suite plugin for which this thing fails declares routes, for example, in the global scope.<br>
<br></div><div>However, with this construction and after slight modifications (changing Dancer to Dancer2, eliminating plugin_args which is not needed after the namespace split) I got an equivalent to Dancer::Plugin::FlashMessage and Dancer::Plugin::Database working.<br>
<br></div><div>This version of Dancer2::Plugin is at <a href="https://github.com/jfraire/Dancer2/blob/master/lib/Dancer2/Plugin.pm">https://github.com/jfraire/Dancer2/blob/master/lib/Dancer2/Plugin.pm</a><br><br></div><div>
Thank you for taking a look into the issue and this proposal.<br><br></div><div>Julio<br></div><br></div>