aboutsummaryrefslogtreecommitdiff
path: root/src/z/Component.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/z/Component.zig')
-rw-r--r--src/z/Component.zig20
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",