summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-05-26 13:55:02 -0500
committerLuke Kanies <luke@madstop.com>2008-06-09 16:40:54 -0500
commit886c984cfc3b944a1c482c1e360bb4fed86a7ed4 (patch)
tree0fabd866d7e4f99ad5afc2ebf093798a4bae4dc3 /lib
parent29c840ae8f2d4e81df1154b1099ce3ca92e348e3 (diff)
downloadpuppet-886c984cfc3b944a1c482c1e360bb4fed86a7ed4.tar.gz
puppet-886c984cfc3b944a1c482c1e360bb4fed86a7ed4.tar.xz
puppet-886c984cfc3b944a1c482c1e360bb4fed86a7ed4.zip
Updating the docs for ResourceTemplate.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/util/resource_template.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/puppet/util/resource_template.rb b/lib/puppet/util/resource_template.rb
index f85078005..cd588902d 100644
--- a/lib/puppet/util/resource_template.rb
+++ b/lib/puppet/util/resource_template.rb
@@ -12,6 +12,29 @@ require 'erb'
# a chunk of text.
# The resource's parameters are available as instance variables
# (as opposed to the language, where we use a method_missing trick).
+# For example, say you have a resource that generates a file. You would
+# need to implement the following style of `generate` method:
+#
+# def generate
+# template = Puppet::Util::ResourceTemplate.new(self, "/path/to/template")
+#
+# return Puppet::Type.type(:file).create :path => "/my/file",
+# :content => template.evaluate
+# end
+#
+# This generated file gets added to the catalog (which is what `generate` does),
+# and its content is the result of the template. You need to use instance
+# variables in your template, so if your template just needs to have the name
+# of the generating resource, it would just have:
+#
+# <%= @name %>
+#
+# Since the ResourceTemplate class sets as instance variables all of the resource's
+# parameters.
+#
+# Note that it sets the generating resource's parameters, which is generally most
+# useful, since it allows you to configure the generated resource via the
+# generating resource.
class Puppet::Util::ResourceTemplate
include Puppet::Util::Logging