Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bare/impl.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions bare/system-agnostic-tests/attributes.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ in
expected = ''<img alt="Photograph" src="photo.jpg">'';
};

testDataAttributes = {
expr =
h "div" {
"data-toggle" = "modal";
"data-target" = "#myModal";
class = "btn";
} [ "Click me" ]
|> serialize;
expected = ''<div class="btn" data-target="#myModal" data-toggle="modal">Click me</div>'';
};

boolean = {
testNonTrue = {
expr = h "br" { inert = false; };
Expand Down
2 changes: 1 addition & 1 deletion dev/modules/website.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
script
;
in
html { lang = "en"; } [
html { lang = "en"; data-theme = "dark"; } [
(head [
(meta { charset = "UTF-8"; })
(meta {
Expand Down