diff options
author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-11 17:04:42 -0700 |
---|---|---|
committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-12 16:12:09 -0700 |
commit | 217c1561a86a76b9570bcc4ab0db31eb25d120fa (patch) | |
tree | ac92353200873874bb1b43bf97fd3a5b88bfd138 /lib | |
parent | ec988e24ce3713a4c4a31918489136f88b6945e6 (diff) | |
download | puppet-217c1561a86a76b9570bcc4ab0db31eb25d120fa.tar.gz puppet-217c1561a86a76b9570bcc4ab0db31eb25d120fa.tar.xz puppet-217c1561a86a76b9570bcc4ab0db31eb25d120fa.zip |
(#6962) Report the template filename for help render errors.
We now set the filename attribute of the ERB instance, which results in any
error messages showing up with the right attribution: to the file they are
defined in, rather than just '(erb)'.
Paired-With: Matt Robinson <matt@puppetlabs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/faces/help.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/puppet/faces/help.rb b/lib/puppet/faces/help.rb index c5f4b0fe6..26f839735 100644 --- a/lib/puppet/faces/help.rb +++ b/lib/puppet/faces/help.rb @@ -39,19 +39,24 @@ Puppet::Faces.define(:help, '0.0.1') do action = (face and actionname) ? face.get_action(actionname.to_sym) : nil template = case args.length - when 0 then erb_template 'global.erb' - when 1 then erb_template 'face.erb' - when 2 then erb_template 'action.erb' + when 0 then erb 'global.erb' + when 1 then erb 'face.erb' + when 2 then erb 'action.erb' else fail ArgumentError, "Too many arguments to help action" end - return ERB.new(template, nil, '%').result(binding) + # Run the ERB template in our current binding, including all the local + # variables we established just above. --daniel 2011-04-11 + return template.result(binding) end end - def erb_template(name) - (Pathname(__FILE__).dirname + "help" + name).read + def erb(name) + template = (Pathname(__FILE__).dirname + "help" + name) + erb = ERB.new(template.read, nil, '%') + erb.filename = template.to_s + return erb end def legacy_applications |