follow PugJs
This commit is contained in:
82
src/root.zig
82
src/root.zig
@@ -1,69 +1,23 @@
|
||||
//! Pugz - A Pug-like HTML template engine written in Zig.
|
||||
//!
|
||||
//! Pugz provides a clean, indentation-based syntax for writing HTML templates,
|
||||
//! inspired by Pug (formerly Jade). It supports:
|
||||
//! - Indentation-based nesting
|
||||
//! - Tag, class, and ID shorthand syntax
|
||||
//! - Attributes and text interpolation
|
||||
//! - Control flow (if/else, each, while)
|
||||
//! - Mixins and template inheritance
|
||||
//!
|
||||
//! ## Quick Start (Server Usage)
|
||||
//!
|
||||
//! ```zig
|
||||
//! const pugz = @import("pugz");
|
||||
//!
|
||||
//! // Initialize view engine once at startup
|
||||
//! var engine = try pugz.ViewEngine.init(allocator, .{
|
||||
//! .views_dir = "src/views",
|
||||
//! });
|
||||
//! defer engine.deinit();
|
||||
//!
|
||||
//! // Render templates (use arena allocator per request)
|
||||
//! var arena = std.heap.ArenaAllocator.init(allocator);
|
||||
//! defer arena.deinit();
|
||||
//!
|
||||
//! const html = try engine.render(arena.allocator(), "pages/home", .{
|
||||
//! .title = "Home",
|
||||
//! });
|
||||
//! ```
|
||||
// Pugz - A Pug-like HTML template engine written in Zig
|
||||
//
|
||||
// Quick Start:
|
||||
// const pugz = @import("pugz");
|
||||
// const engine = pugz.ViewEngine.init(.{ .views_dir = "views" });
|
||||
// const html = try engine.render(allocator, "index", .{ .title = "Home" });
|
||||
|
||||
pub const lexer = @import("lexer.zig");
|
||||
pub const ast = @import("ast.zig");
|
||||
pub const parser = @import("parser.zig");
|
||||
pub const codegen = @import("codegen.zig");
|
||||
pub const runtime = @import("runtime.zig");
|
||||
pub const pug = @import("pug.zig");
|
||||
pub const view_engine = @import("view_engine.zig");
|
||||
pub const diagnostic = @import("diagnostic.zig");
|
||||
pub const template = @import("template.zig");
|
||||
|
||||
// Re-export main types for convenience
|
||||
pub const Lexer = lexer.Lexer;
|
||||
pub const Token = lexer.Token;
|
||||
pub const TokenType = lexer.TokenType;
|
||||
|
||||
pub const Parser = parser.Parser;
|
||||
pub const Node = ast.Node;
|
||||
pub const Document = ast.Document;
|
||||
|
||||
pub const CodeGen = codegen.CodeGen;
|
||||
pub const generate = codegen.generate;
|
||||
|
||||
pub const Runtime = runtime.Runtime;
|
||||
pub const Context = runtime.Context;
|
||||
pub const Value = runtime.Value;
|
||||
pub const render = runtime.render;
|
||||
pub const renderWithOptions = runtime.renderWithOptions;
|
||||
pub const RenderOptions = runtime.RenderOptions;
|
||||
pub const renderTemplate = runtime.renderTemplate;
|
||||
|
||||
// High-level API
|
||||
// Re-export main types
|
||||
pub const ViewEngine = view_engine.ViewEngine;
|
||||
pub const CompiledTemplate = view_engine.CompiledTemplate;
|
||||
pub const compile = pug.compile;
|
||||
pub const compileFile = pug.compileFile;
|
||||
pub const render = pug.render;
|
||||
pub const renderFile = pug.renderFile;
|
||||
pub const CompileOptions = pug.CompileOptions;
|
||||
pub const CompileResult = pug.CompileResult;
|
||||
pub const CompileError = pug.CompileError;
|
||||
|
||||
// Build-time template compilation
|
||||
pub const build_templates = @import("build_templates.zig");
|
||||
pub const compileTemplates = build_templates.compileTemplates;
|
||||
|
||||
test {
|
||||
_ = @import("std").testing.refAllDecls(@This());
|
||||
}
|
||||
// Convenience function for inline templates with data
|
||||
pub const renderTemplate = template.renderWithData;
|
||||
|
||||
Reference in New Issue
Block a user