fix: add scoped error logging for lexer/parser errors
- Add std.log.scoped(.pugz) to template.zig and view_engine.zig - Log detailed error info (code, line, column, message) when parsing fails - Log template path context in ViewEngine on parse errors - Remove debug print from lexer, use proper scoped logging instead - Move benchmarks, docs, examples, playground, tests out of src/ to project root - Update build.zig and documentation paths accordingly - Bump version to 0.3.1
This commit is contained in:
35
tests/test_includes.zig
Normal file
35
tests/test_includes.zig
Normal file
@@ -0,0 +1,35 @@
|
||||
const std = @import("std");
|
||||
const pugz = @import("pugz");
|
||||
|
||||
pub fn main() !void {
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
defer _ = gpa.deinit();
|
||||
const allocator = gpa.allocator();
|
||||
|
||||
// Test: Simple include from test_views
|
||||
var engine = pugz.ViewEngine.init(allocator, .{
|
||||
.views_dir = "test_views",
|
||||
}) 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});
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user