1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! # modo::template
//!
//! MiniJinja-based template rendering for modo.
//!
//! This module provides an opinionated template layer built on top of
//! [MiniJinja](https://docs.rs/minijinja). It covers engine construction,
//! per-request context injection, HTMX-aware rendering, i18n with plural
//! rules, and cache-busted static-asset URLs.
//!
//! ## Provides
//!
//! | Type / Trait | Description |
//! |-----------------------------|-------------|
//! | [`Engine`] / [`EngineBuilder`] | Compile and cache templates from disk, register custom functions and filters, and override the locale resolver chain. |
//! | [`TemplateConfig`] | Configuration for template paths, static-asset prefix, locale defaults, and cookie/query-param names. |
//! | [`TemplateContext`] | Per-request key-value map shared between middleware and handlers; handler values override middleware values on key conflicts. |
//! | [`TemplateContextLayer`] | Tower middleware that injects per-request data (`current_url`, `is_htmx`, `request_id`, `locale`, `csrf_token`, `flash_messages`, and `tier_*` entries) into every request's extensions. Also re-exported as [`modo::middlewares::TemplateContext`](crate::middlewares::TemplateContext). |
//! | [`Renderer`] | Axum extractor that gives handlers a ready-to-use render handle. |
//! | [`HxRequest`] | Infallible axum extractor that detects the `HX-Request: true` header. Also re-exported from [`modo::extractors`](crate::extractors). |
//! | [`context`] | Re-export of [`minijinja::context!`] for building template data in handlers. |
//! | [`LocaleResolver`] | Trait for pluggable locale detection from a request. |
//! | [`QueryParamResolver`] | Resolves the active locale from a URL query parameter. |
//! | [`CookieResolver`] | Resolves the active locale from a cookie. |
//! | [`AcceptLanguageResolver`] | Resolves the active locale from the `Accept-Language` header. |
//! | [`SessionResolver`] | Resolves the active locale from the current session. |
//!
//! ## Quick start
//!
//! ```rust,no_run
//! use modo::template::{Engine, TemplateConfig, TemplateContextLayer};
//!
//! // Build the engine once at startup.
//! let engine = Engine::builder()
//! .config(TemplateConfig::default())
//! .build()
//! .expect("failed to build engine");
//!
//! // Serve static files and inject per-request context.
//! // `Engine` is cheaply cloneable (internal `Arc`).
//! let router: axum::Router = axum::Router::new()
//! .merge(engine.static_service())
//! .layer(TemplateContextLayer::new(engine.clone()));
//! ```
pub use TemplateConfig;
pub use TemplateContext;
pub use ;
pub use HxRequest;
pub use SessionResolver;
pub use ;
pub use TemplateContextLayer;
pub use context;
pub use Renderer;