Gosh I am embarrassed that I didn't notice kallistec's note on conf.d/ files. I was totally consumed with the needs of enterprise java apps :p
On Nov 14, 2012 10:52 PM, "Andrea Campi" < " target="_blank"> > wrote:On Wed, Nov 14, 2012 at 3:29 AM, Daniel DeLeo < " target="_blank"> > wrote:About the implementation, using the lambda as the partial finder is clever, but it'd be nice if it could be done with less magic.On Wed, Nov 14, 2012 at 8:36 AM, Bryan Berry < " target="_blank"> > wrote:echoing Dan's comment on the lambda, why not just make partial_resolver a method inside Chef::Mixin::Template::ChefContext next to your render method ? Do you need the late binding that the lambda gives you?
Chef::Mixin::Template::ChefContext is a "clean slate" that is very careful to expose as little data as possible to the template, so unfortunately that wouldn't work.Chef::Mixin::Template is not possible either, since by design it doesn't know anything about nodes, run contexts and so on. That has value in unit testing and futher.So a closure is a given, I think.What I plan to do to make this more readable is to turn the body of the lambda into a proper method of Chef::Provider::Template. We will still need to pass a proc / lambda into the options hash, but it will be less magic.also, why do you have an if statement in the following, do you expect the partial_resolver to be pluggable or somehow converted to nil ?+ if @partial_resolver+ template_location = @partial_resolver.call(partial_name)+ eruby = Erubis::Eruby.new(IO.read(template_location))+ output = eruby.evaluate(self)+ else+ "foo"+ endYes, kinda. This is defining an API of sorts—it enables any caller of Chef::Mixin::Template::ChefContext to specify this partial_resolver, but they don't have to, it's up to them.If I dropped the if and somebody invoked this "incorrectly", you would get something hard to debug.If instead I replaced "foo" with something like:raise "You cannot render a partial in this context"at least you would have a clear hint of what went wrong.But I have to say, this is pretty hypotetical: in the tree today we have exactly two uses for this mixin: Chef::Provider::Template, and specs.
Archive powered by MHonArc 2.6.16.