From: patrick-scho Date: Tue, 8 Apr 2025 18:54:10 +0000 (+0200) Subject: add ability to specify tag type to html_form X-Git-Url: https://gitweb.ps.run/chirp/commitdiff_plain/d8f54dd8ac187349c1194871a55d4675f28e5a43 add ability to specify tag type to html_form --- diff --git a/src/main.zig b/src/main.zig index 8cabda6..164606f 100644 --- a/src/main.zig +++ b/src/main.zig @@ -509,10 +509,16 @@ fn html_form(res: *http.Response, action: []const u8, inputs: anytype) !void { inline for (inputs) |input| { switch (@typeInfo(@TypeOf(input))) { - .Struct => { - try res.write("", .{}); + .Struct => |s| { + if (s.fields.len == 3) { + try res.write("<{s} ", .{input[0]}); + try res.write(input[1], input[2]); + try res.write(">", .{input[0]}); + } else { + try res.write("", .{}); + } }, else => { try res.write("Description: ", .{}); try html_form(self.res, "/set_description", .{ - .{ "type=\"text\" name=\"description\" placeholder=\"{s}\"", .{login.user.description.constSlice()} }, + .{ "textarea", "type=\"text\" name=\"description\" placeholder=\"{s}\"", .{login.user.description.constSlice()} }, "type=\"submit\" value=\"Change\"", }); try self.res.write("
Password: ", .{});