4 module Puppet::Parser::Functions
5 newfunction(:strip, :type => :rvalue, :doc => <<-DOC
7 This function removes leading and trailing whitespace from a string or from
8 every string inside an array.
11 String or Array converted
16 Would result in: "aaa"
18 > *Note:*: from Puppet 6.0.0, the compatible function with the same name in Puppet core
19 will be used instead of this function.
23 raise(Puppet::ParseError, "strip(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
27 unless value.is_a?(Array) || value.is_a?(String)
28 raise(Puppet::ParseError, 'strip(): Requires either array or string to work with')
31 result = if value.is_a?(Array)
32 value.map { |i| i.is_a?(String) ? i.strip : i }
41 # vim: set ts=2 sw=2 et :