diff --git a/users/sterni/nix/html/default.nix b/users/sterni/nix/html/default.nix index d25a7ab8d..360fa7c47 100644 --- a/users/sterni/nix/html/default.nix +++ b/users/sterni/nix/html/default.nix @@ -29,7 +29,7 @@ let If the content argument is `null`, the tag will have no children nor a closing element. If the content argument is a string it is used as the content as is (unescaped). If the content argument is a list, its - elements are concatenated. + elements are concatenated (recursively if necessary). `renderTag` is only an internal function which is reexposed as `__findFile` to allow for much neater syntax than calling `renderTag` everywhere: @@ -95,7 +95,7 @@ let ); content' = if builtins.isList content - then builtins.concatStringsSep "" content + then builtins.concatStringsSep "" (flatten content) else content; in if content == null @@ -113,6 +113,12 @@ let */ withDoctype = doc: "" + doc; + /* Taken from . */ + flatten = x: + if builtins.isList x + then builtins.concatMap (y: flatten y) x + else [ x ]; + in { inherit escapeMinimal renderTag withDoctype; diff --git a/users/sterni/nix/html/tests/default.nix b/users/sterni/nix/html/tests/default.nix index ed520675c..17662f363 100644 --- a/users/sterni/nix/html/tests/default.nix +++ b/users/sterni/nix/html/tests/default.nix @@ -34,7 +34,13 @@ let (

{ } (esc "html.nix")) (

{ } [ ( { } "the") - (esc " most cursed HTML DSL ever!") + # test flattening + [ + (esc " ") + (esc "most") + [ (esc " cursed ") ] + (esc "HTML DSL ever!") + ] ]) ]) (
{ } [