@@ -167,6 +167,7 @@ the provided regular expression.
167167last Period).
168168* [ ` stdlib::ip_in_range ` ] ( #stdlibip_in_range ) : Returns true if the ipaddress is within the given CIDRs
169169* [ ` stdlib::start_with ` ] ( #stdlibstart_with ) : Returns true if str starts with one of the prefixes given. Each of the prefixes should be a String.
170+ * [ ` stdlib::xml_encode ` ] ( #stdlibxml_encode ) : Encode strings for XML files
170171* [ ` str2bool ` ] ( #str2bool ) : This converts a string to a boolean.
171172* [ ` str2saltedpbkdf2 ` ] ( #str2saltedpbkdf2 ) : Convert a string into a salted SHA512 PBKDF2 password hash like requred for OS X / macOS 10.8+
172173* [ ` str2saltedsha512 ` ] ( #str2saltedsha512 ) : This converts a string to a salted-SHA512 password hash (which is used for
@@ -4300,6 +4301,64 @@ Data type: `Variant[String[1],Array[String[1], 1]]`
43004301
43014302The prefixes to check.
43024303
4304+ ### <a name =" stdlibxml_encode " ></a >` stdlib::xml_encode `
4305+
4306+ Type: Ruby 4.x API
4307+
4308+ This function can encode strings such that they can be used directly in XML files.
4309+ It supports encoding for both XML text (CharData) or attribute values (AttValue).
4310+
4311+ #### Examples
4312+
4313+ ##### Creating an XML file from a template
4314+
4315+ ``` puppet
4316+ file { '/path/to/config.xml':
4317+ ensure => file,
4318+ content => epp(
4319+ 'mymodule/config.xml.epp',
4320+ {
4321+ password => $password.stdlib::xml_encode,
4322+ },
4323+ ),
4324+ }
4325+ ```
4326+
4327+ #### ` stdlib::xml_encode(String $str, Optional[Enum['text','attr']] $type) `
4328+
4329+ This function can encode strings such that they can be used directly in XML files.
4330+ It supports encoding for both XML text (CharData) or attribute values (AttValue).
4331+
4332+ Returns: ` String ` Returns the encoded CharData or AttValue string suitable for use in XML
4333+
4334+ ##### Examples
4335+
4336+ ###### Creating an XML file from a template
4337+
4338+ ``` puppet
4339+ file { '/path/to/config.xml':
4340+ ensure => file,
4341+ content => epp(
4342+ 'mymodule/config.xml.epp',
4343+ {
4344+ password => $password.stdlib::xml_encode,
4345+ },
4346+ ),
4347+ }
4348+ ```
4349+
4350+ ##### ` str `
4351+
4352+ Data type: ` String `
4353+
4354+ The string to encode
4355+
4356+ ##### ` type `
4357+
4358+ Data type: ` Optional[Enum['text','attr']] `
4359+
4360+ Whether to encode for text or an attribute
4361+
43034362### <a name =" str2bool " ></a >` str2bool `
43044363
43054364Type: Ruby 3.x API
0 commit comments