Expand description
Askama template engine integration with HTMX patterns
This module provides:
HxTemplatetrait for automatic partial/full page detection- Template registry with optional caching
- HTMX-aware template helpers
- Integration with axum-htmx response types
§Examples
use askama::Template;
use acton_htmx::template::HxTemplate;
use axum_htmx::HxRequest;
#[derive(Template)]
#[template(source = "<h1>Posts</h1>{% for post in posts %}<p>{{ post }}</p>{% endfor %}", ext = "html")]
struct PostsIndexTemplate {
posts: Vec<String>,
}
async fn index(HxRequest(is_htmx): HxRequest) -> impl axum::response::IntoResponse {
let template = PostsIndexTemplate {
posts: vec!["Post 1".to_string(), "Post 2".to_string()],
};
template.render_htmx(is_htmx)
}Re-exports§
pub use framework::FrameworkTemplateError;pub use framework::FrameworkTemplates;pub use registry::TemplateRegistry;pub use extractor::*;pub use helpers::*;
Modules§
- extractor
- Partial content extraction from rendered templates
- framework
- Framework template system with XDG-compliant storage
- helpers
- Template helper functions for HTMX applications
- registry
- Template registry with caching support
Traits§
- HxTemplate
- Extension trait for Askama templates with HTMX support