I have an html file index_template.html that I then embed and use:
const std = @import("std");
const Index = struct {
document_title: []const u8,
main_title: []const u8,
content: []const u8,
};
pub fn main(init: std.process.Init) !void {
const io = init.io;
const html = @embedFile("index_template.html");
const stdout_file = std.Io.File.stdout();
var buf: [100]u8 = undefined;
var stdout = stdout_file.writer(io, &buf);
const index: Index = .{
.content = "Hello, world",
.document_title = "Doc title",
.main_title = "Guess what?",
};
try stdout.interface.print(html, index);
try stdout.interface.flush();
}
When I run using zig run file.zig it works, but when I change the embedded file, it does not get re-run to incorporate those changes. How can I make that happen?
This is a one-off script for experimentation so I don’t think some of the existing solutions that use the build system would work, but maybe I’m wrong about that?
I thought it was a cache issue, but I’ve removed both .zig-cache and ~/.cache/zig and it doesn’t help.