Open jjn1056 opened 8 years ago
I'm still wondering about this... because it prevents us from optimizing the directives once at instance creation time (and any possible hope of exposing a reflections API) and also I hate to have two ways to do the same thing (one can defer the values of directives via the data that gets passed at render.
Now that you can stick template includes in via $self or $data this is a lot less needed. Putting this one on hold while I ponder what the nicest interface is.
I'm going to leave this on the table for now but I don't think we need it
In the Catalyst view prototype (https://github.com/jjn1056/RangersCCG/blob/master/lib/Catalyst/View/Pure.pm) we allowed that directives could be a code ref instead of an array ref, so that you could generate the directives dynamically at render time based on dependencies and logic that is pre cooked. It feel like a nice feature that belongs in core, would work like
and then invoke like:
$pure->render($data, \@extra_directives, @args)
so allows you to parameterize render a bit.
Things I don't love is positional params in this case, since @extra_directives needs to be undef if you don't need them. Also I sometimes find making things polymorphic like that can lead to confusion down the road. Ideally a deferred directives would be required to declare explicitly its required interface as well. In theory you can do this with something like a Type::Tiny Tuple...