{"id":16692974,"url":"https://github.com/rdbo/dynja","last_synced_at":"2025-03-17T00:33:18.938Z","repository":{"id":216225978,"uuid":"740778569","full_name":"rdbo/dynja","owner":"rdbo","description":"Jinja pseudo-engine focused on DevEx and Performance","archived":false,"fork":false,"pushed_at":"2024-05-20T11:26:59.000Z","size":116,"stargazers_count":26,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T06:41:14.852Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rdbo.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}},"created_at":"2024-01-09T03:33:08.000Z","updated_at":"2025-03-13T20:14:48.000Z","dependencies_parsed_at":"2024-06-11T13:47:45.914Z","dependency_job_id":null,"html_url":"https://github.com/rdbo/dynja","commit_stats":null,"previous_names":["rdbo/dynja"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdbo%2Fdynja","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdbo%2Fdynja/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdbo%2Fdynja/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdbo%2Fdynja/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rdbo","download_url":"https://codeload.github.com/rdbo/dynja/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243955668,"owners_count":20374371,"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":[],"created_at":"2024-10-12T16:29:01.118Z","updated_at":"2025-03-17T00:33:18.711Z","avatar_url":"https://github.com/rdbo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dynja\n![dynja-logo](https://raw.githubusercontent.com/rdbo/dynja/master/LOGO.png)\n### Jinja pseudo-engine focused on DevEx and Performance\n\n## Why Dynja?\nLet's look at two of the alternatives:\n- Askama: extremely fast on benchmarks, but doesn't have a very fun development experience, since you have to recompile your webserver each time you modify a template\n- MiniJinja: decent performance on benchmarks, but has an awesome developer experience, with hot reloading and possibly even live reloading\n\nSo let's mix both: use MiniJinja for debug mode (better DevEx), and Askama for release mode (better performance)\n\nAnd that's what Dynja essentially is\n\n## How to use?\nAdd the `dynja` dependency to your `Cargo.toml`, along with the `askama` dependency. The `minijinja` dependency isn't necessary, because it is only used internally, whereas `askama` needs to be exported on release builds.\n```toml\n[dependencies]\ndynja = { version = \"0.4\", features = [\"askama_release\"] }\naskama = \"0.12\"\n```\n\nNow you can import `dynja` and use it as if it were `askama`. Nice huh?\n```rust\nuse dynja::Template;\n\n#[derive(Template)]\n#[template(path = \"index.html\")]\nstruct MyTemplate {\n    name: \u0026'static str,\n}\n\nfn main() {\n    let template = MyTemplate { name: \"Test\" };\n    println!(\"Template Render: {}\", template.render().unwrap());\n}\n```\nIt will automatically choose between minijinja on debug, and askama on release, so you don't have to worry about it.\n\nNOTE: You can use `dynja` without askama if you wish. Just add the following in your `Cargo.toml` instead:\n```toml\ndynja = \"0.4\"\n```\nIt has optimizations for `minijinja` on release mode as well, but it won't be as performant as `askama`.\n\nRead the [Considerations](#Considerations) section for more information.\n\nHave fun!\n\n## Benchmarks\nNOTE: These benchmarks are not done properly, so they don't represent a real world scenario. They do let you see the difference between switching the engines though.\n\nTested on `dynja_bench`, located on the root directory of this repository.\n\nDynja 0.4.0 (Debug)\n```\nBenchmarking: MiniJinja\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\u003c/head\u003e\n\n  \u003cbody\u003e\n    \u003ch1\u003eDynja Benchmark\u003c/h1\u003e\n    \u003ch2\u003eName: Tests\u003c/h2\u003e\n    \u003ch2\u003eNumber: 1337\u003c/h2\u003e\n    \u003ch2\u003eFloat: 420.0\u003c/h2\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n\nIteration: 999999\nBenchmark finished\nTime taken to finish iterations: 103629ms (103s)\n```\n\nDynja 0.4.0 (Release - `features = [\"askama_release\"]`)\n```\nBenchmarking: Askama\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\u003c/head\u003e\n\n  \u003cbody\u003e\n    \u003ch1\u003eDynja Benchmark\u003c/h1\u003e\n    \u003ch2\u003eName: Tests\u003c/h2\u003e\n    \u003ch2\u003eNumber: 1337\u003c/h2\u003e\n    \u003ch2\u003eFloat: 420\u003c/h2\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n\nIteration: 999999\nBenchmark finished\nTime taken to finish iterations: 937ms (0s)\n```\n\nThe release build finished the iterations about 110 times faster than the debug build.\n\nOn a side note, this benchmark also doesn't say that minijinja is slow by any means.\nIn other to achieve hot reloading of the templates, we have to clear the cached templates of minijinja for every `render()`, which means we add a severe\nbottleneck to its performance to get a better development experience. Here are the results of a test done without the `\"askama_release\"` feature, on release mode:\n\nDynja 0.4.0 (Release)\n```\nBenchmarking: MiniJinja\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\u003c/head\u003e\n\n  \u003cbody\u003e\n    \u003ch1\u003eDynja Benchmark\u003c/h1\u003e\n    \u003ch2\u003eName: Tests\u003c/h2\u003e\n    \u003ch2\u003eNumber: 1337\u003c/h2\u003e\n    \u003ch2\u003eFloat: 420.0\u003c/h2\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n\nIteration: 999999\nBenchmark finished\nTime taken to finish iterations: 2851ms (2s)\n```\n\n## License\nThis project is licensed under the `GNU AGPL-3.0`. No later versions allowed.\n\nRead the `LICENSE` file in the root directory of the project for more information.\n\n## Considerations\nEven though MiniJinja and Askama are both related to Jinja, they are not 100% compatible with each other. So be wary of inconsistencies!\n\nFor most cases, the slower performance of MiniJinja won't affect you as much as you think. In the benchmark above (release mode), it still manage to render the template 350,754 times in a single second, which is more than enough for, say, a web server. If you really need that performance edge and you know that your templates are compatible across the engines, Askama still takes the win with 1,067,235 renders per second, according to the benchmark. If you need to make sure that the debug templates are compatible with release templates, stick with MiniJinja.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdbo%2Fdynja","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frdbo%2Fdynja","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdbo%2Fdynja/lists"}