A lean XML builder for Gleam

only need to add options now

Changed files
+23
src
+23
src/xmleam/xml_builder.gleam
··· 25 25 EncodingEmpty 26 26 TagPlacedBeforeNew 27 27 InnerEmpty 28 + EmptyDocument 28 29 29 30 NOTAPPLICABLE 30 31 } ··· 96 97 } 97 98 } 98 99 100 + /// this starts a block which is a tag with other tags inside of it 101 + /// ie. <owner> 102 + /// <email>example@example.com</email> 103 + /// </owner> 104 + /// 105 + /// Usage: |>block_tag("owner", { 106 + /// new() 107 + /// |> tag("email", "example@example.com") 108 + /// }) 99 109 pub fn block_tag(label: String, inner: XmlBuilder, document: XmlBuilder) { 100 110 let label_empty = string.is_empty(label) 101 111 use <- bool.guard(when: label_empty, return: Error(LabelEmpty)) ··· 123 133 } 124 134 } 125 135 } 136 + 137 + /// this one ends the xml document 138 + /// takes in the Xml Document and outputs 139 + /// a Result(String, BuilderError) 140 + pub fn end_xml(document: XmlBuilder) -> Result(String, BuilderError) { 141 + let document_empty = 142 + string_builder.is_empty(result.unwrap(document, string_builder.new())) 143 + use <- bool.guard(when: document_empty, return: Error(EmptyDocument)) 144 + 145 + result.unwrap(document, string_builder.new()) 146 + |> string_builder.to_string 147 + |> Ok 148 + }