#xml #information #macro #builder #write #ogrim #letting

macro ogrim-macros

Helper crate for ogrim. Please see the docs of ogrim for more information. Do not use this crate directly, API stability is not guaranteed!

3 releases

0.0.3 Nov 15, 2023
0.0.2 Nov 15, 2023
0.0.1 Nov 14, 2023

#1845 in Procedural macros

Download history 27/week @ 2024-01-04 25/week @ 2024-01-11 2/week @ 2024-01-18 6/week @ 2024-02-08 47/week @ 2024-02-15 50/week @ 2024-02-22 24/week @ 2024-02-29 18/week @ 2024-03-07 13/week @ 2024-03-14 3/week @ 2024-03-21 43/week @ 2024-03-28 26/week @ 2024-04-04 3/week @ 2024-04-11

76 downloads per month
Used in ogrim

MIT/Apache

26KB
596 lines

ogrim: macro for building XML from inline XML

CI status of main Crates.io Version docs.rs

XML builder macro letting you write XML inside Rust code (similar to serde_json::json!). Features:

  • Value interpolation (with escaping of course)
    • Interpolate lists or optional attributes with <foo {..iter}>
  • Auto close tags for convenience (e.g. <foo>"body"</>)
  • Minimal memory allocations (only the String being built allocates)
  • Choice between minimized and pretty XML
use ogrim::xml;

let cat_name = "Tony";
let doc = xml!(
    <?xml version="1.0" ?>
    <zoo name="Lorem Ipsum" openingYear={2000 + 13}>
        <cat>{cat_name}</>
        <dog>"Barbara"</>
    </>
);

println!("{}", doc.as_str()); // Print XML

See the documentation for more information and examples.


License

Licensed under either of Apache License, Version 2.0 or MIT license at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~190–255KB