forked from puppetlabs/puppetlabs-stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeferrable_epp.pp
More file actions
18 lines (18 loc) · 743 Bytes
/
deferrable_epp.pp
File metadata and controls
18 lines (18 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# This function returns either a rendered template or a deferred function to render at runtime.
# If any of the values in the variables hash are deferred, then the template will be deferred.
#
# Note: this function requires all parameters to be explicitly passed in. It cannot expect to
# use facts, class variables, and other variables in scope. This is because when deferred, we
# have to explicitly pass the entire scope to the client.
#
function stdlib::deferrable_epp(String $template, Hash $variables) >> Variant[String, Deferred] {
if $variables.any |$key, $value| { $value.is_a(Deferred) } {
Deferred(
'inline_epp',
[find_template($template).file, $variables],
)
}
else {
epp($template, $variables)
}
}