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

Reply via email to