Add user details to template context

This commit is contained in:
jaina heartles 2022-12-13 02:28:25 -08:00
parent 07413747c2
commit 620608964f
1 changed files with 4 additions and 0 deletions

View File

@ -223,6 +223,9 @@ pub const Response = struct {
pub fn template(self: *Self, status_code: http.Status, srv: anytype, comptime templ: []const u8, data: anytype) !void {
try self.headers.put("Content-Type", "text/html");
const user = if (srv.user_id) |uid| try srv.getUser(uid) else null;
defer util.deepFree(srv.allocator, user);
var stream = try self.open(status_code);
defer stream.close();
@ -237,6 +240,7 @@ pub const Response = struct {
data,
.{
.community = srv.community,
.user = user,
.user_id = srv.user_id,
},
);