make it all work
This commit is contained in:
parent
74670edee1
commit
c10587f0c5
16 changed files with 335 additions and 66 deletions
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue