aboutsummaryrefslogtreecommitdiff
path: root/src/zilch/App
diff options
context:
space:
mode:
Diffstat (limited to 'src/zilch/App')
-rw-r--r--src/zilch/App/root.zig16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/zilch/App/root.zig b/src/zilch/App/root.zig
index a7700d9..01e2695 100644
--- a/src/zilch/App/root.zig
+++ b/src/zilch/App/root.zig
@@ -45,7 +45,6 @@ pub fn App(comptime options: Options) type {
break :g gl;
},
- Methods: type = enum(u16) {},
pub const init: @This() = .{};
@@ -56,21 +55,29 @@ pub fn App(comptime options: Options) type {
}
};
} else {
- const components: []const Element = (comp: {
+ const components: []const Element, const registry: []const u8 = (comp: {
var cs: []const Element = &.{};
+ var registry: []const u8 = "const component_registry = {";
for (options.components) |component| {
cs = cs ++ component.toElement();
+ registry = registry ++ std.fmt.comptimePrint("{}: '{s}-{s}',", .{
+ component.id,
+ component.namespace,
+ component.name,
+ });
}
- break :comp cs;
+ registry = registry ++ "};";
+
+ break :comp .{ cs, registry };
});
const functions: []const u8 = func: {
var buf: []const u8 = "ObjectStore.methods = {";
for (options.functions) |function| {
- buf = buf ++ std.fmt.comptimePrint("{}: {s},", .{function.id, function.content});
+ buf = buf ++ std.fmt.comptimePrint("{}: {s},", .{ function.id, function.content });
}
buf = buf ++ "}";
@@ -111,6 +118,7 @@ pub fn App(comptime options: Options) type {
"body",
.{},
&[_]Element{
+ .node("script", .{}, &.{.text(registry)}),
} ++ components ++ options.body.elements,
),
}),