[Dancer-users] [Dancer 2]

damien krotkine dkrotkine at gmail.com
Wed Mar 14 01:34:19 CET 2012


I'm trying to have my Dancer Plugin FlashMessage work with Dancer2.

However, this plugin tries to installs a hook on before_template_render.
This doesn't work in Dancer2 because the 'hook' keyword does
: $self->app->add_hook(...), so it adds the hook on the app instance.
However this app instance only supports these hooks : qw/before after
before_request after_request/  (see Dancer::Core::App::supported_hooks ).

To be able to add a before_template_render, I should access to a template
instance that consumes the Dancer::Core::Role::Template role.

So, basically, the code of 'hook()' in Dancer::Core::DSL should call
add_hook on the app, it should find out which instance the hook should be
added to, and call add_hook on it.

Now that brings up some questions. An easy way would be that there is a
central point that lists all the possible hooks, and which instance (either
the app, or the template engine) ->add_hook should be called upon. But that
breaks the encapsulation (each role advertise which hooks it supports). And
loading every engines to find out which one supports a given hook seems a
bit heavy to me, and prevent the "load only when needed" practice.

So, any idea ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20120314/089ecf55/attachment.htm>

More information about the Dancer-users mailing list