Genearte .zig verions of templates to use in production.

This commit is contained in:
2026-01-28 17:01:28 +05:30
parent 4092e6ad8e
commit 8db2e0df37
1170 changed files with 10153 additions and 3722 deletions

View File

@@ -0,0 +1,33 @@
// Auto-generated helpers for compiled Pug templates
// This file is copied to the generated directory to provide shared utilities
const std = @import("std");
/// Append HTML-escaped string to buffer
pub fn appendEscaped(buf: *std.ArrayListUnmanaged(u8), allocator: std.mem.Allocator, str: []const u8) !void {
for (str) |c| {
switch (c) {
'&' => try buf.appendSlice(allocator, "&"),
'<' => try buf.appendSlice(allocator, "&lt;"),
'>' => try buf.appendSlice(allocator, "&gt;"),
'"' => try buf.appendSlice(allocator, "&quot;"),
'\'' => try buf.appendSlice(allocator, "&#39;"),
else => try buf.append(allocator, c),
}
}
}
/// Check if a value is truthy (for conditionals)
pub fn isTruthy(val: anytype) bool {
const T = @TypeOf(val);
return switch (@typeInfo(T)) {
.bool => val,
.int, .float => val != 0,
.pointer => |ptr| switch (ptr.size) {
.slice => val.len > 0,
else => true,
},
.optional => if (val) |v| isTruthy(v) else false,
else => true,
};
}