From b50e718490abe41f09e16e1edc0d8de93aac8bfe Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Thu, 21 Aug 2008 02:26:25 +1000 Subject: Fixed #1488 - Moved individual functions out of functions.rb into the lib/puppet/parser/functions directory. New functions should be created in this directory. --- lib/puppet/parser/functions/template.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lib/puppet/parser/functions/template.rb (limited to 'lib/puppet/parser/functions/template.rb') diff --git a/lib/puppet/parser/functions/template.rb b/lib/puppet/parser/functions/template.rb new file mode 100644 index 000000000..e62c3b326 --- /dev/null +++ b/lib/puppet/parser/functions/template.rb @@ -0,0 +1,22 @@ +Puppet::Parser::Functions::newfunction(:template, :type => :rvalue, :doc => + "Evaluate a template and return its value. See `the templating docs + `_ for more information. Note that + if multiple templates are specified, their output is all concatenated + and returned as the output of the function.") do |vals| + require 'erb' + + vals.collect do |file| + # Use a wrapper, so the template can't get access to the full + # Scope object. + debug "Retrieving template %s" % file + wrapper = Puppet::Parser::TemplateWrapper.new(self, file) + + begin + wrapper.result() + rescue => detail + raise Puppet::ParseError, + "Failed to parse template %s: %s" % + [file, detail] + end + end.join("") +end -- cgit