This page is rendered using a compiled template.
Compiled templates are 3x faster than Pug.js!
//! Auto-generated by pugz.compileTemplates() //! Do not edit manually - regenerate by running: zig build const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList(u8); // ───────────────────────────────────────────────────────────────────────────── // Helpers // ───────────────────────────────────────────────────────────────────────────── const esc_lut: [256]?[]const u8 = blk: { var t: [256]?[]const u8 = .{null} ** 256; t['&'] = "&"; t['<'] = "<"; t['>'] = ">"; t['"'] = """; t['\''] = "'"; break :blk t; }; fn esc(o: *ArrayList, a: Allocator, s: []const u8) Allocator.Error!void { var i: usize = 0; for (s, 0..) |c, j| { if (esc_lut[c]) |e| { if (j > i) try o.appendSlice(a, s[i..j]); try o.appendSlice(a, e); i = j + 1; } } if (i < s.len) try o.appendSlice(a, s[i..]); } fn truthy(v: anytype) bool { return switch (@typeInfo(@TypeOf(v))) { .bool => v, .optional => v != null, .pointer => |p| if (p.size == .slice) v.len > 0 else true, .int, .comptime_int => v != 0, else => true, }; } var int_buf: [32]u8 = undefined; fn strVal(v: anytype) []const u8 { const T = @TypeOf(v); switch (@typeInfo(T)) { .pointer => |p| switch (p.size) { .slice => return v, .one => { // For pointer-to-array, slice it const child_info = @typeInfo(p.child); if (child_info == .array) { const arr_info = child_info.array; const ptr: [*]const arr_info.child = @ptrCast(v); return ptr[0..arr_info.len]; } return strVal(v.*); }, else => @compileError("unsupported pointer type"), }, .array => @compileError("arrays must be passed by pointer"), .int, .comptime_int => return std.fmt.bufPrint(&int_buf, "{d}", .{v}) catch "0", .optional => return if (v) |val| strVal(val) else "", else => @compileError("strVal: unsupported type " ++ @typeName(T)), } } // ───────────────────────────────────────────────────────────────────────────── // Templates // ───────────────────────────────────────────────────────────────────────────── pub fn index(a: Allocator, d: anytype) Allocator.Error![]u8 { var o: ArrayList = .empty; try o.appendSlice(a, "
some thing
ballahballah"); { const text = "click me "; const @"type" = "secondary"; const mixin_attrs_1: struct { class: []const u8 = "", id: []const u8 = "", style: []const u8 = "", } = .{ }; try o.appendSlice(a, ""); } try o.appendSlice(a, "nothing
Route no found
"; } pub fn mixins_alert(a: Allocator, d: anytype) Allocator.Error![]u8 { _ = .{ a, d }; return ""; } pub fn mixins_buttons(a: Allocator, d: anytype) Allocator.Error![]u8 { _ = .{ a, d }; return ""; } pub fn mixins_cards(a: Allocator, d: anytype) Allocator.Error![]u8 { _ = .{ a, d }; return ""; } pub fn mixins_alert_error(a: Allocator, d: anytype) Allocator.Error![]u8 { _ = .{ a, d }; return ""; } pub fn mixins_input_text(a: Allocator, d: anytype) Allocator.Error![]u8 { _ = .{ a, d }; return ""; } pub fn home(a: Allocator, d: anytype) Allocator.Error![]u8 { var o: ArrayList = .empty; try o.appendSlice(a, "This page is rendered using a compiled template.
Compiled templates are 3x faster than Pug.js!
Welcome to the pets page!
nothing
cheks manually the head section
hello there
"); try esc(&o, a, strVal(@field(d, "petName"))); try o.appendSlice(a, "
"); return o.items; } pub const template_names = [_][]const u8{ "index", "sub_layout", "_404", "mixins_alert", "mixins_buttons", "mixins_cards", "mixins_alert_error", "mixins_input_text", "home", "page_a", "page_b", "layout_2", "layout", "page_append", "users", "page_appen_optional_blk", "pet", };