aboutsummaryrefslogtreecommitdiff
path: root/src/zeroscript/html/Attribute.zig
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-10-12 09:43:19 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2026-10-12 09:43:19 +0200
commit0b2af471b6d5dfc4eaf53639102c1b854bbb324b (patch)
treeaba3943b8c54d26d8552d0685d4178bc995d91c3 /src/zeroscript/html/Attribute.zig
parent812f547d84b5ce1a2924ae16f6257e4fd19efcc0 (diff)
first version of zilch
Diffstat (limited to 'src/zeroscript/html/Attribute.zig')
-rw-r--r--src/zeroscript/html/Attribute.zig45
1 files changed, 0 insertions, 45 deletions
diff --git a/src/zeroscript/html/Attribute.zig b/src/zeroscript/html/Attribute.zig
deleted file mode 100644
index 1db49a0..0000000
--- a/src/zeroscript/html/Attribute.zig
+++ /dev/null
@@ -1,45 +0,0 @@
-const std = @import("std");
-
-const Self = @This();
-
-name: []const u8,
-value: []const u8,
-
-pub fn from(attributes: anytype) []const Self {
- const T = @TypeOf(attributes);
- const info = @typeInfo(T);
-
- if (info != .@"struct") {
- @compileError("struct needed");
- }
-
- const fields = info.@"struct".fields;
-
- var attrs: []const Self = &.{};
-
- for (fields) |field| {
- const name = field.name;
- const value = @field(attributes, name);
-
- const next_attr: []const Self = &.{.{ .name = name, .value = value }};
- attrs = attrs ++ next_attr;
- }
-
- return attrs;
-}
-
-pub fn format(self: *const Self, writer: *std.Io.Writer) !void {
- try writer.writeAll(self.name);
- try writer.writeAll("=\"");
-
- var value: []const u8 = self.value;
-
- while (std.mem.findScalar(u8, value, '"')) |index| {
- try writer.writeAll(value[0..index]);
- try writer.writeAll("&quot;");
- value = value[index + 1..];
- }
-
- try writer.writeAll(value);
- try writer.writeByte('"');
-}