fix a extensibility and test for errors

This commit is contained in:
tristan 2024-01-01 13:48:26 +00:00
parent e76305f71a
commit 3ceb580768
12 changed files with 174 additions and 58 deletions

View file

@ -28,27 +28,31 @@ in rec {
else
keyvalue key value) attrs)));
tag = t: {
tag = t;
attrs = {};
tag = t:
({
tag = t;
attrs = { };
} // baseTag);
baseTag = {
__toString = self: toString (self "");
__functor = self: child:
(if !(isTag child) then
(if isSet child then
self // ({attrs = self.attrs // child;})
incorporateAttrs self child
else
throw "tag child must be tag, list, or string, got ${
builtins.typeOf child
}"
)
else {
tag = t;
attrs = self.attrs;
inherit child;
__toString = toHTML;
});
throw "tag child must be tag, list, or string, got ${
builtins.typeOf child
}")
else
self // {
inherit child;
__toString = toHTML;
});
};
incorporateAttrs = self: attrs: self // ({ attrs = self.attrs // attrs; });
isSet = a: builtins.isAttrs a && !a ? __toString;
isTag = tag: