aboutsummaryrefslogtreecommitdiff
path: root/src/zeroscript/html/element.zig
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-10-09 14:01:20 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2026-10-09 14:01:20 +0200
commit32a251aa9645de070727a6ec91490d3e9219ec7c (patch)
tree5dd55205c5df68fa449e766ec2a8d248e21bd2be /src/zeroscript/html/element.zig
parent09e8d4548361ece6151b914709c39e254eba65e3 (diff)
rename z framework to zeroscript
Diffstat (limited to 'src/zeroscript/html/element.zig')
-rw-r--r--src/zeroscript/html/element.zig30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/zeroscript/html/element.zig b/src/zeroscript/html/element.zig
new file mode 100644
index 0000000..739eb0b
--- /dev/null
+++ b/src/zeroscript/html/element.zig
@@ -0,0 +1,30 @@
+const std = @import("std");
+const mod = @import("root.zig");
+const Attribute = mod.Attribute;
+const Tag = mod.Tag;
+
+pub const Element = union(enum) {
+ const Self = @This();
+
+ tag: Tag,
+ string: []const u8,
+
+ pub fn node(name: []const u8, attributes: anytype, children: []const Element) Self {
+ return .{ .tag = .tag(name, attributes, children) };
+ }
+
+ pub fn @"void"(name: []const u8, attribute: anytype) Self {
+ return .{ .tag = .void(name, attribute) };
+ }
+
+ pub fn text(content: []const u8) Self {
+ return .{ .string = content };
+ }
+
+ pub fn format(self: *const Self, writer: *std.Io.Writer) !void {
+ try switch (self.*) {
+ .string => |content| writer.writeAll(content),
+ .tag => |n| n.format(writer),
+ };
+ }
+};