Can you share some of what the division among the core devs is?
No technical reasons, just matter of taste.
I'm afraid the nested_helpers proposal didn't get enough votes and had to be rejected. :(
package My::Plugin::Frob;
use Mojo::Base 'Mojolicious::Plugin';
use Frob; ## the helper class
has 'frob'; ## this plugin's attribute
sub register {
my ($self, $app, $cfg) = @_;
$self->frob(Frob->new($cfg)); ## create an instance and assign to the attribute
$app->helper(frob => sub { $self->frob }); ## make the helper
...
}
$c->frob->some_method(...);
Lately I've been grouping my helpers into classes with their own namespaces, then creating an instance of the class and invoking it like an object.
It feels and looks like a hack, and is barely better than longer helper names.
Here's also a more minimalistic implementation that only uses a private proxy class.
I think with appropriate warnings in the documentation about potential
leaks in the case you described, it would be something I'd love to see.
> And another problem comes to mind... classes get compiled once a helper
> gets called for the first time, at which point you can't add new nested
> helpers anymore... but application helpers may be called even during
> startup time.
>
> app->foo->bar;
Hmm and that would be a problem since a copious amount of helpers get
called in the startup of the app I mentioned.
So we are back to "only" the leak problem.
So we are back to "only" the leak problem.
...doubles the performance of template helpers by 100%...
And one more change that can double the performance of all helpers in controllers.
On Aug 15, 2014 1:34 AM, "sri" <kra...@googlemail.com> wrote:
>
> https://gist.github.com/anonymous/cbe8fa3dabf6497ec7b9
Wow! That's enormous! What a slight change in the application code for developers to make and what an enormous payback!!
I'm really looking forward to implementing this in my projects!
Thanks for pushing forward to get nested helpers in Mojolicious and to tweak the performance to such drastic improvement.