diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-08 17:44:46 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-08 17:44:46 +0200 |
| commit | 0260f392c19db7911496172c7d43d1178c6215cb (patch) | |
| tree | c5a1f8ff56d3ea727da1d8d29059fc046b102890 /src/z/Component.zig | |
| parent | ec30b659dfd337f5edf512ea78032fe18251b704 (diff) | |
add html parser
Diffstat (limited to 'src/z/Component.zig')
| -rw-r--r-- | src/z/Component.zig | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/z/Component.zig b/src/z/Component.zig index ba328b6..deab261 100644 --- a/src/z/Component.zig +++ b/src/z/Component.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const Fragment = @import("root.zig").html.Fragment; const Element = @import("root.zig").html.Element; const Attribute = @import("root.zig").html.Attribute; const Object = @import("Object.zig"); @@ -6,7 +7,7 @@ const Object = @import("Object.zig"); const Self = @This(); name: []const u8, -html: Element, +html: Fragment, css: []const u8, link: type, @@ -63,7 +64,9 @@ pub fn exportLinks(self: *const Self) void { }, ); - comptime self.exportFromHtml(self.html); + for (self.html.elements) |element| { + comptime self.exportFromHtml(element); + } } fn linkAttributes(self: *const Self, attributes: []const Attribute) []const Attribute { @@ -116,10 +119,17 @@ pub fn toElement(self: *const Self) []const Element { .node( "template", .{ .id = "@" ++ self.name }, - &.{ + [_]Element{ .node("style", .{}, &.{.text(self.css)}), - comptime self.linkHtmlRecursive(self.html), - }, + } ++ (html: { + var elements: []const Element = &.{}; + + for (self.html.elements) |element| { + elements = elements ++ .{self.linkHtmlRecursive(element)}; + } + + break :html elements; + }), ), .node( "script", |