Add user details to template context
This commit is contained in:
parent
07413747c2
commit
620608964f
1 changed files with 4 additions and 0 deletions
|
@ -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 {
|
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");
|
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);
|
var stream = try self.open(status_code);
|
||||||
defer stream.close();
|
defer stream.close();
|
||||||
|
|
||||||
|
@ -237,6 +240,7 @@ pub const Response = struct {
|
||||||
data,
|
data,
|
||||||
.{
|
.{
|
||||||
.community = srv.community,
|
.community = srv.community,
|
||||||
|
.user = user,
|
||||||
.user_id = srv.user_id,
|
.user_id = srv.user_id,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue