From 8c225355d01ea70238a80c58c6d7350cde6dc0e1 Mon Sep 17 00:00:00 2001 From: Mumtahin Farabi Date: Sat, 29 Nov 2025 00:55:06 -0500 Subject: [PATCH 1/2] feat: support "data-*" attributes Signed-off-by: Mumtahin Farabi --- bare/impl.nix | 5 +++-- bare/system-agnostic-tests/attributes.nix | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bare/impl.nix b/bare/impl.nix index 7ae0f15..e2a3285 100644 --- a/bare/impl.nix +++ b/bare/impl.nix @@ -31,9 +31,10 @@ let attribute = tagName: name: value: let - facts = spec.elements.${tagName}.attributes.${name} or null; + attrs = spec.elements.${tagName}.attributes; + facts = attrs.${name} or (if lib.match "^data-.*" name != null then attrs."data-*" else null); in - assert lib.assertMsg (facts != null) "fattribute ${name} not allowed on tag ${tagName}"; + assert lib.assertMsg (facts != null) "attribute ${name} not allowed on tag ${tagName}"; if facts.boolean or false then assert lib.assertMsg value "non-true value for boolean attribute `${name}` of tag `${tagName}`"; value diff --git a/bare/system-agnostic-tests/attributes.nix b/bare/system-agnostic-tests/attributes.nix index d51fa32..5e8cdfb 100644 --- a/bare/system-agnostic-tests/attributes.nix +++ b/bare/system-agnostic-tests/attributes.nix @@ -35,6 +35,17 @@ in expected = ''Photograph''; }; + testDataAttributes = { + expr = + h "div" { + "data-toggle" = "modal"; + "data-target" = "#myModal"; + class = "btn"; + } [ "Click me" ] + |> serialize; + expected = ''
Click me
''; + }; + boolean = { testNonTrue = { expr = h "br" { inert = false; }; From 2bc80eb81f0abb2f91bac61ed0e7e63fb3e2c5df Mon Sep 17 00:00:00 2001 From: Mumtahin Farabi Date: Sat, 29 Nov 2025 01:08:23 -0500 Subject: [PATCH 2/2] feat(dev/modules/website): add `data-theme` attribute to `html` tag Signed-off-by: Mumtahin Farabi --- dev/modules/website.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/modules/website.nix b/dev/modules/website.nix index 17f7909..9cd86ce 100644 --- a/dev/modules/website.nix +++ b/dev/modules/website.nix @@ -35,7 +35,7 @@ script ; in - html { lang = "en"; } [ + html { lang = "en"; data-theme = "dark"; } [ (head [ (meta { charset = "UTF-8"; }) (meta {