d_to_html.d

Biotronic via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Tue Aug 8 02:21:36 PDT 2017


On Sunday, 6 August 2017 at 15:18:29 UTC, Jacob Carlborg wrote:
[snip]
> Wow, that's pretty cool :). One downside I see is that all tags 
> are currently hard coded. This won't work for XML or if using 
> new/custom tags that the library doesn't know about yet.

That's easily amendable:

struct ElementBuilder {
     auto opDispatch(string name, Args...)(Args args) const {
         return Element(name)(args);
     }
}

enum xml = ElementBuilder();

unittest {
     enum a = xml.foo(xml.bar("baz"), xml.qux(123));
     assert(a.toString == 
"<foo><bar>baz</bar><qux>123</qux></foo>");
}

--
   Biotronic


More information about the Digitalmars-d-announce mailing list