https://github.com/chmp/template-fragments-rs
https://github.com/chmp/template-fragments-rs
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/chmp/template-fragments-rs
- Owner: chmp
- License: mit
- Created: 2022-10-24T16:30:09.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-11T17:33:24.000Z (almost 3 years ago)
- Last Synced: 2025-01-12T15:31:00.305Z (over 1 year ago)
- Language: Rust
- Size: 24.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: License.md
Awesome Lists containing this project
README
# `template-fragments` for jinja-like engines
Usage with minijinja (see also [`examples/minijinja.rs`](examples/minijinja.rs)):
```rust
use template_fragments::{join_path, split_templates};
let mut source = minijinja::Source::new();
for (path, template) in [
("index.html", include_str!("templates/index.html")),
("users.html", include_str!("templates/users.html")),
] {
for (fragment_name, template_fragment) in split_templates(template)? {
source.add_template(join_path(path, &fragment_name), &template_fragment)?;
}
}
```