const Minifier = @import("Minifier.zig"); pub fn File(comptime tag: ?[]const u8, comptime minifier: Minifier) type { const opening = if (tag) |t| "<" ++ t ++ ">" else ""; const closing = if (tag) |t| "" else ""; return struct { file: []const u8, do_minify: bool, pub fn path(comptime p: []const u8) @This() { return .{ .file = p, .do_minify = false, }; } pub fn minify(comptime p: []const u8) @This() { return .{ .file = p, .do_minify = true, }; } pub fn to_html_string(comptime self: @This()) []const u8 { return opening ++ (if (self.do_minify) minifier.minify(@embedFile(self.file)) else @embedFile(self.file)) ++ closing; } }; } /// When using regex in Javascript the spaces /// might get trimmed since /re/ is a awful syntax /// I don't what to add a rule for it currently, /// Since a single `/` is a operator but if there are two on one line /// it is a regex. pub const Script = File("script", .js); pub const Style = File("style", .css); pub const Html = File(null, .html);