Skip to content

Instantly share code, notes, and snippets.

@binford2k
Last active June 16, 2017 16:14
Show Gist options
  • Save binford2k/f12a3c05c7933d0ca48bc6c7d56d0725 to your computer and use it in GitHub Desktop.
Save binford2k/f12a3c05c7933d0ca48bc6c7d56d0725 to your computer and use it in GitHub Desktop.
Puppet::Parser::Functions.newfunction(:local_scope,
:type => :rvalue,
:doc => <<-'EOS'
Generates the local scope as a hash. This allows you to use epp functions more
or less like erb templates by passing local scope as the parameters argument.
e.g., `content => epp('mymodname/template.epp', local_scope() )`
EOS
) do |args|
scope = self.to_hash
scope.reject! { |key,val| scope['facts'].include? key }
scope.delete('trusted')
scope.delete('facts')
scope
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment