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; }; 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 {