docs(adr): ADR-0001: Use Tera as Default Template Engine
@aRustyDev 已经在做这个了。
开始于 2026年1月5日。
评估
这个 Issue 还没有评估数据。
描述
ADR-0001: Use Tera as Default Template Engine
Status
Accepted
Context
The mdbook-htmx backend needs a template engine to render HTMX-enhanced HTML pages. The skeleton files indicated support for multiple engines:
- Nunjucks (JavaScript)
- Handlebars (Rust/JS)
- Liquid (Ruby/Rust)
- Tera (Rust-native)
The backend is written in Rust to align with MDBook's ecosystem and ensure seamless integration via the mdbook-renderer crate.
Decision Drivers
- Language Consistency - Backend is Rust; prefer Rust-native engines
- Performance - Compile-time template validation, no FFI overhead
- Feature Parity - Must support: includes, extends, filters, conditionals
- Ecosystem Fit - Used by other Rust documentation tools (Zola)
- Maintenance - Active development, good documentation
Options Considered
Option A: Tera
Pros:
- Pure Rust, compiles with the backend
- Jinja2-compatible syntax (familiar to Python/Django developers)
- Template inheritance (
{% extends %},{% block %}) - Custom filters and functions
- Used by Zola (similar documentation use case)
- Compile-time syntax validation
Cons:
- Less feature-rich than full Jinja2
- Smaller community than Handlebars
Option B: Handlebars (handlebars-rs)
Pros:
- Rust implementation available
- Wide adoption across languages
- Logic-less philosophy (simpler templates)
Cons:
- No template inheritance (only partials)
- Verbose for complex layouts
- Logic-less can be limiting for HTMX patterns
Option C: Liquid (liquid-rust)
Pros:
- Rust implementation available
- Simple syntax
- Used by Jekyll
Cons:
- Limited control flow
- No template inheritance
- Less expressive for component-based layouts
Option D: Nunjucks (via wasm or subprocess)
Pros:
- Full Jinja2 compatibility
- Rich feature set
Cons:
- JavaScript runtime dependency
- Performance overhead (subprocess or WASM)
- Complicates build/distribution
Decision
Use Tera as the default template engine.
Rationale:
- Pure Rust eliminates external dependencies
- Template inheritance is essential for
layout.html→page.htmlpattern - Jinja2 syntax is widely known
- Zola uses Tera for similar documentation purposes, proving suitability
- Custom filters enable
{{ asset('path') }}helper for hashed filenames
Consequences
Positive
- Single-binary distribution (no runtime dependencies)
- Fast template compilation and rendering
- Familiar syntax for most developers
- Strong typing integration with Rust structs
Negative
- Users familiar with Handlebars/Liquid need to learn Tera
- Some advanced Jinja2 features not available
Mitigation
- Document Tera syntax in SPEC
- Provide example templates
- Consider optional Handlebars support in future (via feature flag)
References
- 主要语言
- Rust
- 星标
- 0
- 派生
- 1
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aRustyDev/mdbook-htmx 的其他 Issue
-
feat(ci): Implement cross-repo-validate compliance for docs sync可能重新可做 @aRustyDev 于 291 天前认领,目前没有进行中的 PR。 未关闭ci enhancement
aRustyDev/mdbook-htmx#58 · 1 条评论 · 已指派 1 人 ·
-
docs(htmx): Explain how HTMX works可能重新可做 @aRustyDev 于 294 天前认领,目前没有进行中的 PR。 未关闭
aRustyDev/mdbook-htmx#48 · 3 条评论 · 已指派 1 人 ·
-
docs(mdbook-htmx): Parent Issue for documentation可能重新可做 @aRustyDev 于 294 天前认领,目前没有进行中的 PR。 未关闭documentation
aRustyDev/mdbook-htmx#47 · 已指派 1 人 ·
-
docs(examples): Secure Self-Hosted Meilisearch via Cloudflare可能重新可做 @aRustyDev 于 294 天前认领,目前没有进行中的 PR。 未关闭documentation
aRustyDev/mdbook-htmx#46 · 已指派 1 人 ·
-
docs(examples): Kubernetes with Meilisearch可能重新可做 @aRustyDev 于 294 天前认领,目前没有进行中的 PR。 未关闭documentation
aRustyDev/mdbook-htmx#45 · 已指派 1 人 ·
查看 aRustyDev/mdbook-htmx 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 73/100
haowjy/mars-agents#228 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 68/100
redlib-org/redlib#604 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
dividebysandwich/rust-dos#240 ·
维护者通常 1 天内回复
-
A-UI C-Bug S-Needs-Triage
难度 2/5 1-3 小时 新手友好度 75/100
bevyengine/bevy#26330 ·
维护者通常 2 天内回复