2026-01-25 15:23:57 +05:30
|
|
|
const std = @import("std");
|
|
|
|
|
const pugz = @import("pugz");
|
|
|
|
|
|
|
|
|
|
pub fn main() !void {
|
|
|
|
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
|
|
|
|
defer _ = gpa.deinit();
|
|
|
|
|
const allocator = gpa.allocator();
|
|
|
|
|
|
2026-01-25 16:35:27 +05:30
|
|
|
// Test: Simple include from test_views
|
2026-01-25 15:23:57 +05:30
|
|
|
var engine = pugz.ViewEngine.init(allocator, .{
|
2026-01-27 15:09:08 +05:30
|
|
|
.views_dir = "tests/sample/01",
|
2026-01-25 15:23:57 +05:30
|
|
|
}) catch |err| {
|
|
|
|
|
std.debug.print("Init Error: {}\n", .{err});
|
|
|
|
|
return err;
|
|
|
|
|
};
|
|
|
|
|
defer engine.deinit();
|
|
|
|
|
|
|
|
|
|
const html = engine.render(allocator, "home", .{}) catch |err| {
|
|
|
|
|
std.debug.print("Error: {}\n", .{err});
|
|
|
|
|
return err;
|
|
|
|
|
};
|
|
|
|
|
defer allocator.free(html);
|
|
|
|
|
|
|
|
|
|
std.debug.print("=== Rendered HTML ===\n{s}\n=== End ===\n", .{html});
|
2026-01-25 16:35:27 +05:30
|
|
|
|
|
|
|
|
// Verify output contains included content
|
|
|
|
|
if (std.mem.indexOf(u8, html, "Included Partial") != null and
|
|
|
|
|
std.mem.indexOf(u8, html, "info-box") != null)
|
|
|
|
|
{
|
|
|
|
|
std.debug.print("\nSUCCESS: Include directive works correctly!\n", .{});
|
|
|
|
|
} else {
|
|
|
|
|
std.debug.print("\nFAILURE: Include content not found!\n", .{});
|
|
|
|
|
return error.TestFailed;
|
|
|
|
|
}
|
2026-01-25 15:23:57 +05:30
|
|
|
}
|