files: std.ArrayListUnmanaged(File),
pub fn init(allocator: std.mem.Allocator) Template {
return .{ .allocator = allocator, .files = std.ArrayListUnmanaged(File).empty };
}
pub fn deinit(self: *Template) void {
self.files.deinit(self.allocator);
}
pub fn addFile(self: *Template, path: ?[]const u8, name: []const u8, content: []const u8) void {
self.files.append(self.allocator, File.init(path, name, content)) catch {
std.process.fatal("If this can be comptime I wont need this !!!! :3", .{});
};
}
pub fn write(...) void {
// do runtime stuff with files
}
Hi, I am looking for resources that will teach me how to make my above struct be able to have files added to it during comptime, so I don't have to allocate memory to add files. Below is what I would like
var template = Template.init(); //comptime
template.addFile(null, "init.lua", @embedFile(
"../lua/templates/channel/init.lua",
)); //comptime
template.addFile("packages", "init.lua", @embedFile(
"../lua/templates/channel/packages/init.lua",
)); //comptime
template.write(path); //runtime