Puppet Function: tp_content

Defined in:
lib/puppet/parser/functions/tp_content.rb
Function type:
Ruby 3.x API

Overview

tp_content()Any

Takes an optional content and an optional template name to calculate the actual contents of a file.

This small function abbreviates the default initialisation boilerplate of stdmod modules.

Returns:

  • (Any)


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/puppet/parser/functions/tp_content.rb', line 2

Puppet::Parser::Functions.newfunction(:tp_content,
                                      :type => :rvalue,
                                      :doc => <<-'ENDOFDOC'
Takes an optional content and an optional template name to calculate the actual
contents of a file.

This small function abbreviates the default initialisation boilerplate of
stdmod modules.
ENDOFDOC
) do |args|
  content = args[0]
  template_name = args[1]
  epp_name = args[2]

  Puppet::Parser::Functions.autoloader.loadall

  return content if content != ''
  return function_template([template_name]) if template_name != ''
  return function_epp([epp_name]) if epp_name != ''

  return :undef
end