- demo build fix.

- README changes for bench values.
This commit is contained in:
2026-01-28 19:38:59 +05:30
parent 8db2e0df37
commit e2025d7de8
4 changed files with 172 additions and 67 deletions

View File

@@ -39,27 +39,10 @@ pub fn build(b: *std.Build) void {
// ===========================================================================
// Main Executable
// ===========================================================================
// Check if compiled templates exist
const has_templates = blk: {
var dir = std.fs.cwd().openDir("generated", .{}) catch break :blk false;
dir.close();
break :blk true;
};
// Build imports list
var imports: std.ArrayListUnmanaged(std.Build.Module.Import) = .{};
defer imports.deinit(b.allocator);
imports.append(b.allocator, .{ .name = "pugz", .module = pugz_mod }) catch @panic("OOM");
imports.append(b.allocator, .{ .name = "httpz", .module = httpz_dep.module("httpz") }) catch @panic("OOM");
// Only add templates module if they exist
if (has_templates) {
const templates_mod = b.createModule(.{
.root_source_file = b.path("generated/root.zig"),
});
imports.append(b.allocator, .{ .name = "templates", .module = templates_mod }) catch @panic("OOM");
}
// Templates module - uses output from compile step
const templates_mod = b.createModule(.{
.root_source_file = compile_templates.getOutput(),
});
const exe = b.addExecutable(.{
.name = "demo",
@@ -67,10 +50,17 @@ pub fn build(b: *std.Build) void {
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = imports.items,
.imports = &.{
.{ .name = "pugz", .module = pugz_mod },
.{ .name = "httpz", .module = httpz_dep.module("httpz") },
.{ .name = "templates", .module = templates_mod },
},
}),
});
// Ensure templates are compiled before building the executable
exe.step.dependOn(&compile_templates.step);
b.installArtifact(exe);
// Run step

View File

@@ -242,8 +242,7 @@ fn home(app: *App, _: *httpz.Request, res: *httpz.Response) !void {
break :blk try templates.pages_home.render(res.arena, .{
.title = "Home",
.cartCount = "2",
.authenticated = true,
.items = sample_products,
.authenticated = "true",
});
} else app.view.render(res.arena, "pages/home", .{
.title = "Home",
@@ -315,7 +314,6 @@ fn cart(app: *App, _: *httpz.Request, res: *httpz.Response) !void {
.subtotal = sample_cart.subtotal,
.tax = sample_cart.tax,
.total = sample_cart.total,
.cartItems = &sample_cart_items,
});
} else app.view.render(res.arena, "pages/cart", .{
.title = "Shopping Cart",