Sha256: 8cb4ff52615755229d107ba21f84f90ad3d239d0964fc580c8863b291fdbdd7f

Contents?: true

Size: 1.24 KB

Versions: 242

Compression:

Stored size: 1.24 KB

Contents

Puppet::Parser::Functions::newfunction(:template, :type => :rvalue, :arity => -2, :doc =>
  "Loads an ERB template from a module, evaluates it, and returns the resulting
  value as a string.

  The argument to this function should be a `<MODULE NAME>/<TEMPLATE FILE>`
  reference, which will load `<TEMPLATE FILE>` from a module's `templates`
  directory. (For example, the reference `apache/vhost.conf.erb` will load the
  file `<MODULES DIRECTORY>/apache/templates/vhost.conf.erb`.)

  This function can also accept:

  * An absolute path, which can load a template file from anywhere on disk.
  * Multiple arguments, which will evaluate all of the specified templates and
  return their outputs concatenated into a single string.") do |vals|
    vals.collect do |file|
      # Use a wrapper, so the template can't get access to the full
      # Scope object.
      debug "Retrieving template #{file}"

      wrapper = Puppet::Parser::TemplateWrapper.new(self)
      wrapper.file = file
      begin
        wrapper.result
      rescue => detail
        info = detail.backtrace.first.split(':')
        raise Puppet::ParseError,
          "Failed to parse template #{file}:\n  Filepath: #{info[0]}\n  Line: #{info[1]}\n  Detail: #{detail}\n"
      end
    end.join("")
end

Version data entries

242 entries across 242 versions & 2 rubygems

Version Path
puppet-retrospec-1.8.0 vendor/pup410/lib/puppet/parser/functions/template.rb
puppet-retrospec-1.7.0 vendor/pup410/lib/puppet/parser/functions/template.rb
puppet-4.10.12 lib/puppet/parser/functions/template.rb
puppet-4.10.12-x86-mingw32 lib/puppet/parser/functions/template.rb
puppet-4.10.12-x64-mingw32 lib/puppet/parser/functions/template.rb
puppet-4.10.12-universal-darwin lib/puppet/parser/functions/template.rb
puppet-4.10.11 lib/puppet/parser/functions/template.rb
puppet-4.10.11-x86-mingw32 lib/puppet/parser/functions/template.rb
puppet-4.10.11-x64-mingw32 lib/puppet/parser/functions/template.rb
puppet-4.10.11-universal-darwin lib/puppet/parser/functions/template.rb
puppet-4.10.10 lib/puppet/parser/functions/template.rb
puppet-4.10.10-x86-mingw32 lib/puppet/parser/functions/template.rb
puppet-4.10.10-x64-mingw32 lib/puppet/parser/functions/template.rb
puppet-4.10.10-universal-darwin lib/puppet/parser/functions/template.rb
puppet-retrospec-1.6.1 vendor/pup410/lib/puppet/parser/functions/template.rb
puppet-retrospec-1.6.0 vendor/pup410/lib/puppet/parser/functions/template.rb
puppet-4.10.9 lib/puppet/parser/functions/template.rb
puppet-4.10.9-x86-mingw32 lib/puppet/parser/functions/template.rb
puppet-4.10.9-x64-mingw32 lib/puppet/parser/functions/template.rb
puppet-4.10.9-universal-darwin lib/puppet/parser/functions/template.rb