elemi.attribute

Holds the Attribute type which can be passed to elem to add attributes to XML and HTML elements.

Members

Functions

attr
Attribute attr()
Attribute attr(string name, string value)

Create an XML/HTML attribute.

attr
Attribute attr(string name)
Attribute attr(string value)

Create an XML/HTML attribute.

Structs

Attribute
struct Attribute

Represents an XML/HTML attribute. It can be easily created with the attr function.

Examples

import elemi.xml;

// Create new attributes with `attr`
auto a = attr("key") = "value";
assert(a == `key="value"`);

// And pass them to elements
assert(elem!"div"(a) == `<div key="value"></div>`);

assert(elem!"div"(
    attr("key") = "value",
    attr("class") = "one two three",
) == `<div key="value" class="one two three"></div>`);

Meta