Help with macros needed

I'm trying to create my own template generation tool for HTML, which I want to look like this:

(!DOCTYPE)[HTML]
(html){
    (head){(title){Page Title}}
    (body){
        (h1){Heading}[.class #id hidden attr:value "attr two":"value two"]
        (p){Paragraph of Text}[.p-class #p-id]
    }
}[lang:en]

I'm trying to come up with a way to use macro_rules! for this, but I've gotten a bit stuck at this:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=3f6f0fbc6e8666fa5c1461c81f13ef21

How do I make the macro recursive, for it to be able to call itself for tags which come next, as well for tags, included in {content}? Is the macro the wrong tool for the job here? Or what am I missing?

This seems relevant: https://doc.rust-lang.org/1.7.0/book/macros.html#recursive-macros

1 Like

may be helpful. It hasn't been updated for a long time though.
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.