{"id":16856335,"url":"https://github.com/kijewski/nate","last_synced_at":"2026-03-04T03:02:07.027Z","repository":{"id":39858522,"uuid":"390256426","full_name":"Kijewski/nate","owner":"Kijewski","description":"Not a Template Engine for Rust","archived":false,"fork":false,"pushed_at":"2025-02-04T06:24:50.000Z","size":158,"stargazers_count":5,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-22T17:11:24.168Z","etag":null,"topics":["derive","escape","html","no-std","rust","template-engine"],"latest_commit_sha":null,"homepage":"https://docs.rs/nate","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kijewski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-07-28T07:29:11.000Z","updated_at":"2024-12-25T16:31:57.000Z","dependencies_parsed_at":"2023-12-14T12:15:06.066Z","dependency_job_id":"65ddfd06-7234-47a6-9f9e-07b266cf9692","html_url":"https://github.com/Kijewski/nate","commit_stats":{"total_commits":68,"total_committers":4,"mean_commits":17.0,"dds":0.3088235294117647,"last_synced_commit":"99e8be4c0e47bff59c522ae4498ab0031dd9f77d"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/Kijewski/nate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kijewski%2Fnate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kijewski%2Fnate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kijewski%2Fnate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kijewski%2Fnate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kijewski","download_url":"https://codeload.github.com/Kijewski/nate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kijewski%2Fnate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30070479,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T01:03:42.280Z","status":"online","status_checked_at":"2026-03-04T02:00:07.464Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["derive","escape","html","no-std","rust","template-engine"],"created_at":"2024-10-13T14:03:41.484Z","updated_at":"2026-03-04T03:02:07.014Z","avatar_url":"https://github.com/Kijewski.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"## NaTE — Not a Template Engine\n\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/Kijewski/nate/ci.yml?branch=main)](https://github.com/Kijewski/nate/actions/workflows/ci.yml)\n[![Crates.io](https://img.shields.io/crates/v/nate?logo=rust)](https://crates.io/crates/nate)\n![Minimum supported Rust version](https://img.shields.io/badge/rustc-1.56+-important?logo=rust \"Minimum Supported Rust Version\")\n[![License](https://img.shields.io/badge/license-Apache--2.0%20WITH%20LLVM--exception-informational?logo=apache)](https://github.com/Kijewski/nate/blob/v0.2.2/LICENSE \"Apache-2.0 WITH LLVM-exception\")\n\nThis is *not* a template engine, but sugar to implicitly call `write!(…)` like in PHP.\nThe only difference is that the output gets XML escaped automatically unless opted-out explicitly.\n\nUnlike other template engines like\n[Askama](https://crates.io/crates/askama), [Handlebars](https://crates.io/crates/handlebars),\n[Liquid](https://github.com/cobalt-org/liquid-rust), [Tera](https://crates.io/crates/tera), or\n[Tide](https://crates.io/crates/tide), you don't have to learn a new language.\nIf you know Rust and HTML, you already know how to implement templates with NaTE!\n\nE.g.\n\n*   templates/greeting.html:\n\n    ```xml\n    \u003ch1\u003eHello, {{user}}!\u003c/h1\u003e\n    ```\n\n    The path is relative to the cargo manifest dir (where you find Cargo.toml) of the project.\n\n*   src/main.rs:\n\n    ```rust\n    use nate::Nate;\n    \n    #[derive(Nate)]\n    #[template(path = \"templates/greeting.html\")]\n    struct Greetings\u003c'a\u003e {\n        user: \u0026'a str,\n    }\n    \n    fn main() {\n        let mut output = String::new();\n        let tmpl = Greetings { user: \"\u003cWorld\u003e\" };\n        write!(output, \"{}\", tmpl).unwrap();\n        println!(\"{}\", output);\n    }\n    ```\n\n*   Output:\n\n    ```html\n    \u003ch1\u003eHello, \u0026#60;World\u0026#62;!\u003c/h1\u003e\n    ```\n\nNo new traits are needed, instead `#[derive(Nate)]` primarily works by implementing fmt::Display.\nThis also makes nesting of NaTE templates possible.\n\nA more complex example would be:  \n\n*   src/main.rs:\n\n    ```rust\n    use nate::Nate;\n\n    #[derive(Nate)]\n    #[template(path = \"templates/99-bottles.html\")]\n    struct Template {\n        limit: usize,\n    }\n\n    #[test]\n    fn ninetynine_bottles_of_beer() {\n        print!(\"{}\", Template { limit: 99 });\n    }\n    ```\n\n*   templates/99-bottles.txt:\n\n    ```jinja\n    {%-\n        for i in (1..=self.limit).rev() {\n            if i == 1 {\n    -%}\n    1 bottle of beer on the wall.\n    1 bottle of beer.\n    Take one down, pass it around.\n    {%-\n            } else {\n    -%}\n    {{i}} bottles of beer on the wall.\n    {{i}} bottles of beer.\n    Take one down, pass it around.\n\n    {%\n            }\n        }\n    -%}\n    ```\n\nInside of a `{% code block %}` you can write any and all rust code.\n\nValues in `{{ value blocks }}` are printed XML escaped.\n\nValues in `{{{ raw blocks }}}` are printed verbatim.\n\nFor values in `{{{{ debug blocks }}}}` their debug message is printed as in `\"{:?}\"`.\n\nFor values in `{{{{{ verbose blocks }}}}}` their debug message is printed verbose as in `\"{:#?}\"`.\n\nWith `{\u003c include \u003e}` blocks you can include a template file.\nIt then behaves like it was copy-pasted into the current file.\nIf the path starts with \".\" or \"..\", the file is searched relative to the current file.\nOtherwise it is search in the project root.\n\nUsing hyphens `-` at the start/end of a block, whitespaces before/after the block are trimmed.\n\nData blocks `{{…}}` to `{{{{{…}}}}}` and includes `{\u003c…\u003e}` must not be empty.\nCode `{%…%}` and comment `{#…#}` blocks may be empty.\n\nBlocks don't need to be closed at the end of the file.\n\nTo debug any errors you can add an argument as in `#[template(generated = \"some/path/generated.rs\")]`.\nThe generated code is stored in there even if there were parsing errors in the Rust code.\nThe path is relative to the project root (where your Cargo.toml lives).\n\n## Feature flags\n\n* *std* \u003csup\u003e\\[enabled by default\\]\u003c/sup\u003e — enable features found in [std](https://doc.rust-lang.org/stable/std/) crate, e.g. printing the value of a `MutexGuard`\n\n* *alloc* \u003csup\u003e\\[enabled by default, enabled by `std`\\]\u003c/sup\u003e — enable features found in the [alloc](https://doc.rust-lang.org/stable/alloc/) crate, e.g. `io::Write`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkijewski%2Fnate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkijewski%2Fnate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkijewski%2Fnate/lists"}