mirror of
https://github.com/jetzig-framework/jetzig.git
synced 2025-05-14 14:06:08 +00:00
Merge pull request #46 from jetzig-framework/replicate-exe-imports
Replicate exe imports
This commit is contained in:
commit
c2cc9c50f2
@ -146,7 +146,12 @@ pub fn jetzigInit(b: *std.Build, exe: *std.Build.Step.Compile, options: JetzigIn
|
||||
});
|
||||
|
||||
exe.root_module.addImport("routes", routes_module);
|
||||
routes_module.addImport("jetzig", jetzig_module);
|
||||
|
||||
var it = exe.root_module.import_table.iterator();
|
||||
while (it.next()) |import| {
|
||||
routes_module.addImport(import.key_ptr.*, import.value_ptr.*);
|
||||
exe_static_routes.root_module.addImport(import.key_ptr.*, import.value_ptr.*);
|
||||
}
|
||||
|
||||
exe_static_routes.root_module.addImport("routes", routes_module);
|
||||
exe_static_routes.root_module.addImport("jetzig", jetzig_module);
|
||||
|
@ -191,6 +191,13 @@ pub fn run(
|
||||
github_url,
|
||||
});
|
||||
|
||||
try util.runCommand(allocator, realpath, &[_][]const u8{
|
||||
"zig",
|
||||
"fetch",
|
||||
"--save",
|
||||
"https://github.com/jetzig-framework/iguanas/archive/89c2abf29de0bc31054a9a6feac5a6a83bab0459.tar.gz",
|
||||
});
|
||||
|
||||
// TODO: Use arg or interactive prompt to do Git setup in net project, default to no.
|
||||
// const git_setup = false;
|
||||
// if (git_setup) try gitSetup(allocator, install_dir);
|
||||
|
@ -12,6 +12,12 @@ pub fn build(b: *std.Build) !void {
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
// Example dependency:
|
||||
const iguanas_dep = b.dependency("iguanas", .{ .optimize = optimize, .target = target });
|
||||
exe.root_module.addImport("iguanas", iguanas_dep.module("iguanas"));
|
||||
|
||||
// All dependencies **must** be added to imports above this line.
|
||||
|
||||
try jetzig.jetzigInit(b, exe, .{});
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
@ -6,6 +6,10 @@
|
||||
.jetzig = .{
|
||||
.path = "../",
|
||||
},
|
||||
.iguanas = .{
|
||||
.url = "https://github.com/jetzig-framework/iguanas/archive/89c2abf29de0bc31054a9a6feac5a6a83bab0459.tar.gz",
|
||||
.hash = "12202fd319a5ab4e124b00e8ddea474d07c19c4e005d77b6c29fc44860904ea01a5c",
|
||||
},
|
||||
},
|
||||
.paths = .{
|
||||
// This makes *all* files, recursively, included in this package. It is generally
|
||||
|
@ -1,5 +1,6 @@
|
||||
const std = @import("std");
|
||||
const jetzig = @import("jetzig");
|
||||
const iguanas = @import("iguanas");
|
||||
|
||||
/// This example uses a layout. A layout is a template that exists in `src/app/views/layouts` and
|
||||
/// references `{zmpl.content}`.
|
||||
@ -11,7 +12,21 @@ const jetzig = @import("jetzig");
|
||||
/// and `demo/src/app/views/iguanas/index.zmpl`
|
||||
pub const layout = "application";
|
||||
|
||||
pub fn index(request: *jetzig.StaticRequest, data: *jetzig.Data) !jetzig.View {
|
||||
_ = data;
|
||||
pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
|
||||
var root = try data.array();
|
||||
|
||||
const params = try request.params();
|
||||
|
||||
const count = if (params.get("iguanas")) |param|
|
||||
try std.fmt.parseInt(usize, param.string.value, 10)
|
||||
else
|
||||
10;
|
||||
|
||||
const iguanas_slice = try iguanas.iguanas(request.allocator, count);
|
||||
|
||||
for (iguanas_slice) |iguana| {
|
||||
try root.append(data.string(iguana));
|
||||
}
|
||||
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
@ -1,3 +1,6 @@
|
||||
<div>
|
||||
<span>Content goes here</span>
|
||||
var it = zmpl.value.?.array.iterator();
|
||||
while (it.next()) |iguana| {
|
||||
<div>{(iguana.string.value)}</div>
|
||||
}
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user