From 6eddcabb8cf86c7da88d690734fd492b9615c4ec Mon Sep 17 00:00:00 2001 From: Ankit Patial Date: Fri, 30 Jan 2026 23:14:28 +0530 Subject: [PATCH] fix: skip mixin definitions in codegen to prevent duplicate rendering Mixin definitions from included files were being rendered as content. Now generateNode explicitly skips mixin definitions (node.call=false) while still processing expanded mixin calls. Bump version to 0.3.12 --- build.zig.zon | 2 +- src/tpl_compiler/zig_codegen.zig | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 60b5e78..6c5465b 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .pugz, - .version = "0.3.11", + .version = "0.3.12", .fingerprint = 0x822db0790e17621d, // Changing this has security and trust implications. .minimum_zig_version = "0.15.2", .dependencies = .{}, diff --git a/src/tpl_compiler/zig_codegen.zig b/src/tpl_compiler/zig_codegen.zig index 4e78116..dc82abb 100644 --- a/src/tpl_compiler/zig_codegen.zig +++ b/src/tpl_compiler/zig_codegen.zig @@ -190,6 +190,21 @@ pub const Codegen = struct { .Conditional => try self.generateConditional(node), .Each, .EachOf => try self.generateEach(node), .TypeHint => {}, // Skip - processed during field extraction + .Mixin => { + // Skip mixin definitions (call=false), only process mixin calls (call=true) + // Mixin calls should already be expanded by mixin.expandMixins() + if (!node.call) return; + // If somehow a mixin call wasn't expanded, process its children + for (node.nodes.items) |child| { + try self.generateNode(child); + } + }, + .Include => { + // Process included content (children were inlined by processIncludes) + for (node.nodes.items) |child| { + try self.generateNode(child); + } + }, else => { // Unsupported nodes: skip or process children for (node.nodes.items) |child| {