make it all work

This commit is contained in:
tristan 2023-12-31 00:24:48 +00:00
parent 74670edee1
commit c10587f0c5
16 changed files with 335 additions and 66 deletions

View file

@ -4,15 +4,33 @@ rec {
then elem
else if builtins.typeOf elem == "list"
then builtins.toString (map toHTML elem)
else ''<${elem.tag}>${toHTML elem.child}</${elem.tag}>'';
else ''<${elem.tag} ${writeAttrs elem.attrs}>${toHTML elem.child}</${elem.tag}>'';
writeAttrs = attrs:
toString builtins.attrValues (
toString (builtins.attrValues (
builtins.mapAttrs (key: value: ''${key}="${value}"'') attrs
);
));
tag = tag: child: {
inherit tag child;
tag = tag: attrs: child: {
inherit tag child attrs;
__toString = toHTML;
};
addToHead = page: heads:
page
// {
child =
map
(
e:
if e.tag == "head"
then
e
// {
child = e.child ++ heads;
}
else e
)
page.child;
};
}