jetzig/demo/src/app/views/iguanas.zig
Bob Farrell aa036fde8b Implement layouts
Latest Zmpl provides `template.renderWithLayout(other_template, data)`,
allowing a template to be renedered within another template.

Create layouts in `src/app/views/layouts/` or use
`jetzig generate layout [name]` and set `pub const layout = "name";` in
each view file.
2024-03-11 22:36:18 +00:00

18 lines
602 B
Zig

const std = @import("std");
const jetzig = @import("jetzig");
/// This example uses a layout. A layout is a template that exists in `src/app/views/layouts` and
/// references `{zmpl.content}`.
///
/// The content is the rendered template for the current view which is then injected into the
/// layout in place of `{zmpl.content}`.
///
/// See `demo/src/app/views/layouts/application.zmpl`
/// and `demo/src/app/views/iguanas/index.zmpl`
pub const layout = "application";
pub fn index(request: *jetzig.StaticRequest, data: *jetzig.Data) !jetzig.View {
_ = data;
return request.render(.ok);
}