{"id":24752211,"url":"https://github.com/rinja-rs/rinja","last_synced_at":"2025-03-05T02:05:25.866Z","repository":{"id":244798627,"uuid":"816314127","full_name":"rinja-rs/rinja","owner":"rinja-rs","description":"A template rendering engine based on Jinja, generating type-safe Rust code at compile time.","archived":false,"fork":false,"pushed_at":"2024-10-20T15:33:29.000Z","size":2479,"stargazers_count":125,"open_issues_count":18,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-20T17:45:53.279Z","etag":null,"topics":["html","jinja","rust","template-engine"],"latest_commit_sha":null,"homepage":"https://rinja.readthedocs.io","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/rinja-rs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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}},"created_at":"2024-06-17T13:42:32.000Z","updated_at":"2024-10-20T15:33:33.000Z","dependencies_parsed_at":"2024-06-28T23:20:48.790Z","dependency_job_id":"9e282c1c-6d46-43a4-8a01-d76e36d480ad","html_url":"https://github.com/rinja-rs/rinja","commit_stats":null,"previous_names":["rinja-rs/rinja"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rinja-rs%2Frinja","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rinja-rs%2Frinja/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rinja-rs%2Frinja/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rinja-rs%2Frinja/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rinja-rs","download_url":"https://codeload.github.com/rinja-rs/rinja/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241950145,"owners_count":20047591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["html","jinja","rust","template-engine"],"created_at":"2025-01-28T10:36:49.952Z","updated_at":"2025-03-05T02:05:25.845Z","avatar_url":"https://github.com/rinja-rs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rinja\n\n[![Crates.io](https://img.shields.io/crates/v/rinja?logo=rust\u0026style=flat-square\u0026logoColor=white \"Crates.io\")](https://crates.io/crates/rinja)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/rinja-rs/rinja/rust.yml?branch=master\u0026logo=github\u0026style=flat-square\u0026logoColor=white \"GitHub Workflow Status\")](https://github.com/rinja-rs/rinja/actions/workflows/rust.yml)\n[![Book](https://img.shields.io/readthedocs/rinja?label=book\u0026logo=readthedocs\u0026style=flat-square\u0026logoColor=white \"Book\")](https://rinja.readthedocs.io/)\n[![docs.rs](https://img.shields.io/docsrs/rinja?logo=docsdotrs\u0026style=flat-square\u0026logoColor=white \"docs.rs\")](https://docs.rs/rinja/)\n\n**Rinja** implements a template rendering engine based on [Jinja](https://jinja.palletsprojects.com/),\nand generates type-safe Rust code from your templates at compile time\nbased on a user-defined `struct` to hold the template's context.\nSee below for an example. It is a fork of [Askama](https://crates.io/crates/askama), please have a look at our\n[blog post](https://blog.guillaume-gomez.fr/articles/2024-07-31+docs.rs+switching+jinja+template+framework+from+tera+to+rinja)\nhighlighting differences between the two crates.\n\nAll feedback welcome! Feel free to file bugs, requests for documentation and\nany other feedback to the [issue tracker][issues].\n\nYou can find the documentation about our syntax, features, configuration in our book:\n[rinja.readthedocs.io](https://rinja.readthedocs.io/).\n\nHave a look at our [*Rinja Playground*](https://rinja-rs.github.io/play-rinja/),\nif you want to try out rinja's code generation online.\n\n### Feature highlights\n\n* Construct templates using a familiar, easy-to-use syntax\n* Benefit from the safety provided by Rust's type system\n* Template code is compiled into your crate for optimal performance\n* Debugging features to assist you in template development\n* Templates must be valid UTF-8 and produce UTF-8 when rendered\n* Works on stable Rust\n\n### Supported in templates\n\n* Template inheritance\n* Loops, if/else statements and include support\n* Macro support\n* Variables (no mutability allowed)\n* Some built-in filters, and the ability to use your own\n* Whitespace suppressing with '-' markers\n* Opt-out HTML escaping\n* Syntax customization\n\n[issues]: https://github.com/rinja-rs/rinja/issues\n\n\nHow to get started\n------------------\n\nFirst, add the rinja dependency to your crate's `Cargo.toml`:\n\n```sh\ncargo add rinja\n```\n\nNow create a directory called `templates` in your crate root.\nIn it, create a file called `hello.html`, containing the following:\n\n```jinja\nHello, {{ name }}!\n```\n\nIn any Rust file inside your crate, add the following:\n\n```rust\nuse rinja::Template; // bring trait in scope\n\n#[derive(Template)] // this will generate the code...\n#[template(path = \"hello.html\")] // using the template in this path, relative\n                                 // to the `templates` dir in the crate root\nstruct HelloTemplate\u003c'a\u003e { // the name of the struct can be anything\n    name: \u0026'a str, // the field name should match the variable name\n                   // in your template\n}\n\nfn main() {\n    let hello = HelloTemplate { name: \"world\" }; // instantiate your struct\n    println!(\"{}\", hello.render().unwrap()); // then render it.\n}\n```\n\nYou should now be able to compile and run this code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frinja-rs%2Frinja","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frinja-rs%2Frinja","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frinja-rs%2Frinja/lists"}