Fix panic when mixin not found with relative mixins_dir path
The loadMixinFromDir function used openDirAbsolute which requires an absolute path, but ViewEngine passes a relative path for mixins_dir. This caused a panic when a mixin call couldn't find the mixin in the current template. Fix: Check if mixins_dir is absolute and use the appropriate method: - std.fs.openDirAbsolute() for absolute paths - std.fs.cwd().openDir() for relative paths
This commit is contained in:
@@ -867,7 +867,11 @@ pub const Runtime = struct {
|
||||
}
|
||||
|
||||
// Second try: iterate through all .pug files in mixins directory
|
||||
var dir = std.fs.openDirAbsolute(self.mixins_dir, .{ .iterate = true }) catch return null;
|
||||
// Use cwd().openDir for relative paths, openDirAbsolute for absolute paths
|
||||
var dir = if (std.fs.path.isAbsolute(self.mixins_dir))
|
||||
std.fs.openDirAbsolute(self.mixins_dir, .{ .iterate = true }) catch return null
|
||||
else
|
||||
std.fs.cwd().openDir(self.mixins_dir, .{ .iterate = true }) catch return null;
|
||||
defer dir.close();
|
||||
|
||||
var iter = dir.iterate();
|
||||
|
||||
Reference in New Issue
Block a user