18 lines
436 B
Nix
18 lines
436 B
Nix
rec {
|
|
toHTML = elem:
|
|
if builtins.typeOf elem == "string"
|
|
then elem
|
|
else if builtins.typeOf elem == "list"
|
|
then builtins.toString (map toHTML elem)
|
|
else ''<${elem.tag}>${toHTML elem.child}</${elem.tag}>'';
|
|
|
|
writeAttrs = attrs:
|
|
toString builtins.attrValues (
|
|
builtins.mapAttrs (key: value: ''${key}="${value}"'') attrs
|
|
);
|
|
|
|
tag = tag: child: {
|
|
inherit tag child;
|
|
__toString = toHTML;
|
|
};
|
|
}
|