| Crates.io | skabelon |
| lib.rs | skabelon |
| version | 0.1.18 |
| created_at | 2025-11-25 15:00:44.366694+00 |
| updated_at | 2025-12-09 12:05:06.501399+00 |
| description | Simple templating engine for rust using angular syntax |
| homepage | |
| repository | https://github.com/sofusa/skabelon |
| max_upload_size | |
| id | 1949913 |
| size | 70,345 |
Simple templating engine for rust, using Angular syntax. You can use the build-in Angular parser from Prettier for formatting.
templates.reload().@if() {} @else if() {} @else {} support.@for() {} support for iteration.@defer {} support for partials. Partials can have a {{ content }} where block from @defer will be rendered.object["value"] or object.value for accessing object valuesTemplates can be loaded with a glob or string.
let mut templates = Templates::new();
templates.load_glob("templates/**/*.html");
let template_str =
"<table>@for(row in table) {<tr>@for(col in row) {<td>{{col}}</td>}</tr>}</table>";
templates.load_str("template", template_str);
Templates are rendered with:
let ctx = json!({"table": table});
let render = templates.render("big-table.html", &ctx);
// or for load_str
let render = templates.render("template", &ctx);
Context can be referenced in templates with {{ key }}.
If key is an object, values can be referenced with {{ key["value"] }} or {{ key.value }}.
If key is an array, array can be indexed with {{ key[index] }}.
@ifSupports ==, !=, &&, ||, <, >, <=, >=,
@if (condition) {
block
}
@if (condition) {
block
} @else {
otherwhere
}
@if (condition) {
block
} @else if (condition) {
block
}
@if (condition) {
block
} @else if (condition) {
block
} @else {
otherwhere
}
@forIterates over array. index is added to the context:
@for (item in items) {
{{index}}: {{item}}
}
@defer@defer (key) {}
main
@defer (partial) {Hello}
partial
{{ content }} World
@defer (key; value="hello") {}
or for variables
@defer (key; value=variable) {}