blob: d90ed3b1bb8e8d63544dfed5c1d6e8d48eb5e96c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
const std = @import("std");
const File = @import("File.zig");
const Self = @This();
name: []const u8,
parent_dir: []const u8,
pub fn path(p: []const u8) Self {
const name = p[if (std.mem.lastIndexOfScalar(
u8,
std.mem.trim(u8, p, "/"),
'/',
)) |index| index + 1 else 0..];
return .{
.name = name,
.parent_dir = p,
};
}
pub fn to_html_string(comptime self: Self) []const u8 {
const html: File.Html = .minify(self.parent_dir ++ "/index.html");
const js: File.Script = .minify(self.parent_dir ++ "/index.js");
const css: File.Style = .minify(self.parent_dir ++ "/index.css");
return "<template id=\"--" ++ self.name ++ "\">" ++ css.to_html_string() ++ html.to_html_string() ++ js.to_html_string() ++ "</template>";
}
test {}
|