summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/parser/templatewrapper.rb6
-rwxr-xr-xspec/unit/parser/templatewrapper.rb9
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/puppet/parser/templatewrapper.rb b/lib/puppet/parser/templatewrapper.rb
index 00f364088..036f6604e 100644
--- a/lib/puppet/parser/templatewrapper.rb
+++ b/lib/puppet/parser/templatewrapper.rb
@@ -83,7 +83,11 @@ class Puppet::Parser::TemplateWrapper
# to the regular methods.
benchmark(:debug, "Bound template variables for #{file}") do
scope.to_hash.each { |name, value|
- realname = name.gsub(/[^\w]/, "_")
+ if name.kind_of?(String)
+ realname = name.gsub(/[^\w]/, "_")
+ else
+ realname = name
+ end
instance_variable_set("@#{realname}", value)
}
end
diff --git a/spec/unit/parser/templatewrapper.rb b/spec/unit/parser/templatewrapper.rb
index 6dbfbe266..532776223 100755
--- a/spec/unit/parser/templatewrapper.rb
+++ b/spec/unit/parser/templatewrapper.rb
@@ -86,6 +86,15 @@ describe Puppet::Parser::TemplateWrapper do
@tw.instance_variable_get("@one").should == "foo"
end
+ it "should not error out if one of the variables is a symbol" do
+ template_mock = mock("template", :result => "woot!")
+ File.expects(:read).with("/tmp/fake_template").returns("template contents")
+ ERB.expects(:new).with("template contents", 0, "-").returns(template_mock)
+
+ @scope.expects(:to_hash).returns(:_timestamp => "1234")
+ @tw.result
+ end
+
%w{! . ; :}.each do |badchar|
it "should translate #{badchar} to _ when setting the instance variables" do
template_mock = mock("template", :result => "woot!")