#xml #inline #embed #macro

inline-xml

Embed XML data directly in your Rust code

11 releases

0.3.2 May 18, 2023
0.3.1 Apr 8, 2023
0.2.5 Apr 6, 2023
0.2.3 Mar 7, 2023
0.1.2 Mar 6, 2023

#11 in #embed

Download history 8/week @ 2023-07-26 3/week @ 2023-08-02 28/week @ 2023-08-09 18/week @ 2023-08-16 16/week @ 2023-08-23 7/week @ 2023-08-30 170/week @ 2023-09-06 315/week @ 2023-09-13 377/week @ 2023-09-20 316/week @ 2023-09-27 309/week @ 2023-10-04 305/week @ 2023-10-11 246/week @ 2023-10-18 306/week @ 2023-10-25 34/week @ 2023-11-01 13/week @ 2023-11-08

633 downloads per month
Used in inline-css

LGPL-3.0-or-later

30KB
690 lines

inline-xml

Inline XML data directly into your Rust code.

Example

use inline_xml::xml;

fn main() {
    let value = 42;
    let html = xml! {
        <html>
            <head>
                <title>Example</title>
            </head>
            <body>
                <h1>Example</h1>
                <p>Hello World</p>
                <p>Value: {value}</p>
            </body>
        </html>
    };
    
    println!("{html}");
}

Syntax issues

Since Rust will tokenize the input and proc_macro_span is not stabilized, whitespace will be discarded and therefore inline_xml has to guess about where to put whitespace when printing.

TODO

  • Eliminate usage of Content::Nested completely
  • More documentation
  • Mention, in the docs, that struct Xml can take multiple tags
  • Make struct Tag an instance of trait ToXml
  • Arg -> Attr, args -> attrs
  • Fix XML injection for attributes
  • Fix interpretation of floating point literals
  • Somehow produce XML & DTD declarations (probably as a format arg)
  • Namespaces (eg. <a:x>asdf</a:x>)

Dependencies

~1MB
~31K SLoC