fix a extensibility and test for errors
This commit is contained in:
parent
e76305f71a
commit
3ceb580768
12 changed files with 174 additions and 58 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue