| Crates.io | minilate |
| lib.rs | minilate |
| version | 0.1.1 |
| created_at | 2025-06-08 04:46:51.069974+00 |
| updated_at | 2025-06-08 09:04:03.749651+00 |
| description | A minimal templating library for Rust |
| homepage | |
| repository | https://github.com/josiahbull/minilate |
| max_upload_size | |
| id | 1704605 |
| size | 174,300 |
A templating engine prioritising minimal binary size and speed at the cost of feature set.
use minilate::{MinilateEngine, Context, VariableTy, MinilateInterface};
// Create engine and add template
let mut engine = MinilateEngine::new();
engine.add_template("hello", "Hello, {{ name }}!").unwrap();
// Create context
let mut context = Context::new();
context.insert("name", VariableTy::String.with_data("World".to_string()));
// Render
let result = engine.render("hello", Some(&context)).unwrap();
assert_eq!(result, "Hello, World!");
Minilate is designed for only a core feature set, but maximised performance and minimised binary size.
| Engine | Binary Size | Rel. Size | Time/Template | Rel. Perf. |
|---|---|---|---|---|
| Minilate | 1.56 MB | 1.00x | 205.08 ยตs | 1.00x |
| Handlebars | 1.75 MB | 1.12x | 776.79 ยตs | 3.79x |
| MiniJinja | 2.00 MB | 1.28x | 438.03 ยตs | 2.154 |
๐ Minilate achieves 12-28% smaller binaries while being ~2-4x faster than alternatives.
Benchmarks: 100 complex templates ร 50 iterations each. Template includes conditionals, loops, and nested data. See Benchmarking for details.
{{ variable }}{{% if <condition> %}}, {{% else if %}}, and {{% else %}}
!&&||{{% for var in iterable %}}{{<< <template_file_name>.tmpl }}\{{ or \{{%Add this to your Cargo.toml:
[dependencies]
minilate = "0.1"
Welcome to {{ site_name }}!
Your username is {{ user.name }}.
{{% if user && is_active %}}
Hello, {{ user }}! You have {{ message_count }} new messages.
{{% elif !is_active %}}
Your account is inactive. Please contact support.
{{% else %}}
Hello, Guest! Please log in to continue.
{{% endif %}}
# Shopping Cart
{{% if items %}}
Total items: {{ item_count }}
{{% for item in items %}}
- {{ item.name }} ({{ item.quantity }}x) - ${{ item.price }}
{{% if item.special %}}**ON SALE!**{{% endif %}}
{{% endfor %}}
Total: ${{ total_price }}
{{% else %}}
Your cart is empty.
{{% endif %}}
{{<< header.tmpl }}
# Main Content
{{ content }}
{{<< footer.tmpl }}
# User Profile: {{ user.name }}
{{% if user.active %}}
**Status:** Active User (Age: {{ user.age }})
{{% if show_details && has_access %}}
## Recent Activity
{{% for activity in recent_activities %}}
- {{ activity.date }}: {{ activity.description }}
{{% if activity.important %}}โ ๏ธ **Important**{{% endif %}}
{{% endfor %}}
{{% elif !has_access %}}
*You don't have permission to view activity details*
{{% endif %}}
{{% else %}}
**Status:** Inactive User
{{% endif %}}
To run benchmarks locally:
./scripts/benchmark.sh
This script:
The benchmark tests template rendering with:
Licensed under either of
at your option.
Contributions are welcome! Please feel free to submit a Pull Request.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.