summaryrefslogtreecommitdiff
path: root/lib/chef/mixin/template.rb
diff options
context:
space:
mode:
authorAndrea Campi <andrea.campi@zephirworks.com>2012-11-18 23:24:49 +0100
committerBryan McLellan <btm@opscode.com>2012-12-14 11:10:28 -0800
commit3dd9365d285bd1bd316be6270e108a229595668a (patch)
tree7de2d64c7f8f30d5fe163af6ca686c569c8202db /lib/chef/mixin/template.rb
parent5509897b9f0a536f6b3768f28f569d450ff53232 (diff)
downloadchef-3dd9365d285bd1bd316be6270e108a229595668a.tar.gz
[CHEF-3249] Refactor template name resolution out to a separate class for DRYness and readability. While here let's also extend the API to support local templates, as well as templates from other cookbooks.
Diffstat (limited to 'lib/chef/mixin/template.rb')
-rw-r--r--lib/chef/mixin/template.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/chef/mixin/template.rb b/lib/chef/mixin/template.rb
index c25f5f6e1f..9288264fcd 100644
--- a/lib/chef/mixin/template.rb
+++ b/lib/chef/mixin/template.rb
@@ -30,10 +30,10 @@ class Chef
"include a node variable if you plan to use it."
end
- def render(partial_name, variables = nil)
- raise "You cannot render partials in this context" unless @partial_resolver
+ def render(partial_name, options = {})
+ raise "You cannot render partials in this context" unless @template_finder
- if variables
+ if variables = options.delete(:variables)
context = {}
context.merge!(variables)
context[:node] = node
@@ -41,7 +41,7 @@ class Chef
context = self.dup
end
- template_location = @partial_resolver.call(partial_name)
+ template_location = @template_finder.find(partial_name, options)
eruby = Erubis::Eruby.new(IO.read(template_location))
output = eruby.evaluate(context)
end