summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/files.rb10
-rw-r--r--lib/puppet/parser/templatewrapper.rb7
2 files changed, 7 insertions, 10 deletions
diff --git a/lib/puppet/parser/files.rb b/lib/puppet/parser/files.rb
index ca4fb4f10..749428e9f 100644
--- a/lib/puppet/parser/files.rb
+++ b/lib/puppet/parser/files.rb
@@ -41,7 +41,7 @@ module Puppet::Parser::Files
if template_paths = templatepath(environment)
# If we can find the template in :templatedir, we return that.
- td_file = template_paths.collect { |path|
+ template_paths.collect { |path|
File::join(path, template)
}.each do |f|
return f if FileTest.exist?(f)
@@ -49,11 +49,11 @@ module Puppet::Parser::Files
end
# check in the default template dir, if there is one
- unless td_file = find_template_in_module(template, environment)
- raise Puppet::Error, "No valid template directory found, please check templatedir settings" if template_paths.nil?
- td_file = File::join(template_paths.first, template)
+ if td_file = find_template_in_module(template, environment)
+ return td_file
end
- td_file
+
+ return nil
end
def find_template_in_module(template, environment = nil)
diff --git a/lib/puppet/parser/templatewrapper.rb b/lib/puppet/parser/templatewrapper.rb
index 8b333a0b6..00faf33a1 100644
--- a/lib/puppet/parser/templatewrapper.rb
+++ b/lib/puppet/parser/templatewrapper.rb
@@ -65,11 +65,8 @@ class Puppet::Parser::TemplateWrapper
end
def file=(filename)
- @file = Puppet::Parser::Files.find_template(filename, scope.compiler.environment)
-
- unless FileTest.exists?(file)
- raise Puppet::ParseError,
- "Could not find template %s" % file
+ unless @file = Puppet::Parser::Files.find_template(filename, scope.compiler.environment)
+ raise Puppet::ParseError, "Could not find template '%s'" % filename
end
# We'll only ever not have a parser in testing, but, eh.