aboutsummaryrefslogtreecommitdiff
path: root/src/eval/math.zig
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-04-30 17:56:55 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2026-04-30 17:56:55 +0200
commita13df3ca580dc31544ef092d5d37e18089af3517 (patch)
treecfcf8c1d8322ee8e97783e263105eac9f5c00f33 /src/eval/math.zig
parent5ecd48d4b9f928beb4143f88e802ee4d9e25a2bd (diff)
refactor(element): generalize element creation
Diffstat (limited to 'src/eval/math.zig')
-rw-r--r--src/eval/math.zig11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/eval/math.zig b/src/eval/math.zig
index 20d3fec..aeec997 100644
--- a/src/eval/math.zig
+++ b/src/eval/math.zig
@@ -54,12 +54,7 @@ fn Math(comptime template: []const u8) type {
}
pub fn element(self: *Self) Element {
- return .{ .ptr = self, .vtable = .{ .html = html, .node = getNode } };
- }
-
- fn getNode(context: *anyopaque) *Node {
- const self: *Self = @ptrCast(@alignCast(context));
- return &self.node;
+ return Element.Wrapper(Self, html).init(self);
}
fn fromNode(context: *anyopaque) Element {
@@ -67,10 +62,8 @@ fn Math(comptime template: []const u8) type {
return self.element();
}
- fn html(context: *anyopaque, alloc: Allocator) HTML.Error!HTML {
- const self: *Self = @ptrCast(@alignCast(context));
+ fn html(self: *Self, alloc: Allocator) HTML.Error!HTML {
const content = self.content orelse return (try HTML.Literal.init(alloc, "")).element();
-
var arena = std.heap.ArenaAllocator.init(alloc);
defer arena.deinit();
const escaped = try escape(arena.allocator(), content);