1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
const std = @import("std");
pub const Minifier = @import("Minifier.zig");
pub const Component = @import("Component.zig");
pub const File = @import("File.zig");
const Element = @import("html").Element;
pub const script: File = .{
.tag = .script,
.minifier = .js,
};
pub const style: File = .{
.tag = .style,
.minifier = .css,
};
pub const body: File = .{
.tag = .body,
.minifier = .html,
};
pub const html: File = .{
.tag = null,
.minifier = .html,
};
pub fn env(comptime components: []const Component) Element {
var children: []const Element = &.{
script.load(@embedFile("z.js")),
script.load(@embedFile("rest.js")),
};
inline for (components) |c| {
const child: []const Element = &.{c.toElement()};
children = children ++ child;
}
return .transparent(.children(children));
}
pub fn component(kind: @EnumLiteral(), attrs: anytype, content: Element.Content) Element {
var element: Element = .native(.@"z-component", attrs, content);
const type_attr: []const Element.Attribute = &.{.{
.name = "type",
.value = @tagName(kind),
}};
element.attributes = type_attr ++ element.attributes;
return element;
}
test {
_ = std.testing.refAllDecls(@This());
}
|