Skip to content

Commit 9ed7967

Browse files
authored
Merge pull request #4 from davidnuon/strings-as-textnode
Add support for strings as children
2 parents 01fa44e + 662a0c0 commit 9ed7967

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/internal.nix

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ in rec {
1414
inherit name attributes children;
1515
};
1616

17+
string2textNode = el:
18+
if builtins.typeOf el == "string"
19+
then text {text = [el];}
20+
else el;
21+
1722
/*
1823
Makes a funciton that models an element with no specific attributes
1924
(e.g div, p, strong)
@@ -23,7 +28,8 @@ in rec {
2328
children ? [],
2429
}:
2530
basicElement {
26-
inherit name attributes children;
31+
inherit name attributes;
32+
children = map string2textNode children;
2733
};
2834

2935
text = with builtins;

0 commit comments

Comments
 (0)