Remove Rules type
This commit is contained in:
parent
614607ae71
commit
6494bbdf60
2 changed files with 5 additions and 10 deletions
|
|
@ -16,7 +16,7 @@ pub fn run(allocator: std.mem.Allocator, params: *jetzig.data.Value, env: jetzig
|
|||
return;
|
||||
},
|
||||
};
|
||||
const out_rules = Data.Rules{ .rules = &[_]Data.Rule{rule} };
|
||||
const out_rules = &[_]Data.Rule{rule};
|
||||
const out = try std.json.stringifyAlloc(allocator, out_rules, .{});
|
||||
try file.writeAll(out);
|
||||
file.close();
|
||||
|
|
@ -35,18 +35,17 @@ pub fn run(allocator: std.mem.Allocator, params: *jetzig.data.Value, env: jetzig
|
|||
|
||||
const file_write: std.fs.File = try std.fs.cwd().openFile("rules.json", .{ .mode = .write_only });
|
||||
if (file_content.len == 0) {
|
||||
const out_rules = Data.Rules{ .rules = &[_]Data.Rule{rule} };
|
||||
const out_rules = &[_]Data.Rule{rule};
|
||||
const out = try std.json.stringifyAlloc(allocator, out_rules, .{});
|
||||
try file_write.writeAll(out);
|
||||
file_write.close();
|
||||
return;
|
||||
}
|
||||
const content: Data.Rules = try std.json.parseFromSliceLeaky(Data.Rules, allocator, file_content, .{});
|
||||
try rules.appendSlice(content.rules);
|
||||
const content: []Data.Rule = try std.json.parseFromSliceLeaky([]Data.Rule, allocator, file_content, .{});
|
||||
try rules.appendSlice(content);
|
||||
try rules.append(rule);
|
||||
|
||||
const out_rules = Data.Rules{ .rules = rules.items };
|
||||
const out = try std.json.stringifyAlloc(allocator, out_rules, .{});
|
||||
const out = try std.json.stringifyAlloc(allocator, rules.items, .{});
|
||||
|
||||
try file_write.writeAll(out);
|
||||
file_write.close();
|
||||
|
|
|
|||
|
|
@ -95,10 +95,6 @@ pub const Rule = struct {
|
|||
},
|
||||
};
|
||||
|
||||
pub const Rules = struct {
|
||||
rules: []const Rule,
|
||||
};
|
||||
|
||||
// Can't import types in .zmpl files, so defining this here
|
||||
// doesn't really do much (except maybe in the .zig file for views?)
|
||||
//pub const HeaderTypes = []enum {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue