A lean XML builder for Gleam
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

added CDATA tag and a test for it

+24 -2
+1 -1
gleam.toml
··· 1 name = "xmleam" 2 - version = "1.1.3" 3 4 # Fill out these fields if you intend to generate HTML documentation or publish 5 # your project to the Hex package manager.
··· 1 name = "xmleam" 2 + version = "1.1.4" 3 4 # Fill out these fields if you intend to generate HTML documentation or publish 5 # your project to the Hex package manager.
+12
src/xmleam.gleam
··· 46 } 47 48 io.println(result.unwrap(document, "ERROR")) 49 }
··· 46 } 47 48 io.println(result.unwrap(document, "ERROR")) 49 + 50 + let document = { 51 + xml_builder.new() 52 + |> xml_builder.cdata_tag( 53 + "link", 54 + "<a href=\"https://example.com\"> link </a>", 55 + ) 56 + |> xml_builder.end_xml 57 + |> result.unwrap("ERROR") 58 + } 59 + 60 + io.debug(document) 61 }
+11 -1
test/xmleam_test.gleam
··· 1 import gleeunit 2 import gleeunit/should 3 import xmleam/xml_builder.{ 4 Opt, block_tag, end_xml, new, option_block_tag, option_content_tag, option_tag, 5 tag, 6 } 7 - import gleam/result 8 9 pub fn main() { 10 gleeunit.main() ··· 14 pub fn hello_world_test() { 15 1 16 |> should.equal(1) 17 } 18 19 ///Test all of the functions
··· 1 + import gleam/result 2 import gleeunit 3 import gleeunit/should 4 import xmleam/xml_builder.{ 5 Opt, block_tag, end_xml, new, option_block_tag, option_content_tag, option_tag, 6 tag, 7 } 8 9 pub fn main() { 10 gleeunit.main() ··· 14 pub fn hello_world_test() { 15 1 16 |> should.equal(1) 17 + } 18 + 19 + pub fn xml_builder_cdata_test() { 20 + xml_builder.new() 21 + |> xml_builder.cdata_tag("link", "<a href=\"https://example.com\"> link </a>") 22 + |> xml_builder.end_xml 23 + |> result.unwrap("ERROR") 24 + |> should.equal( 25 + "<link> \n<![CDATA[\n \t<a href=\"https://example.com\"> link </a>\n]]> \n</link> \n", 26 + ) 27 } 28 29 ///Test all of the functions