{"id":13440057,"url":"https://github.com/kaj/ructe","last_synced_at":"2025-05-14T13:08:08.987Z","repository":{"id":44589457,"uuid":"68322328","full_name":"kaj/ructe","owner":"kaj","description":"Rust Compiled Templates with static-file handling","archived":false,"fork":false,"pushed_at":"2025-02-06T23:41:42.000Z","size":827,"stargazers_count":456,"open_issues_count":17,"forks_count":32,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-13T12:41:30.341Z","etag":null,"topics":["html","template-engine","web"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/ructe","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kaj.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2016-09-15T18:55:13.000Z","updated_at":"2025-02-18T22:44:02.000Z","dependencies_parsed_at":"2024-06-09T10:39:25.187Z","dependency_job_id":"9dffdade-54c5-44b4-8d0d-5eb709d77ded","html_url":"https://github.com/kaj/ructe","commit_stats":{"total_commits":556,"total_committers":13,"mean_commits":42.76923076923077,"dds":0.0809352517985612,"last_synced_commit":"4065b75e69926a8daaaa4510bb971077ea56b4c1"},"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaj%2Fructe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaj%2Fructe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaj%2Fructe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaj%2Fructe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaj","download_url":"https://codeload.github.com/kaj/ructe/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254149960,"owners_count":22022851,"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","template-engine","web"],"created_at":"2024-07-31T03:01:19.423Z","updated_at":"2025-05-14T13:08:03.977Z","avatar_url":"https://github.com/kaj.png","language":"Rust","readme":"# Rust Compiled Templates — ructe\n\nThis is my attempt at writing a HTML template system for Rust.\nSome inspiration comes from the scala template system used in play 2,\nas well as plain old jsp.\n\n[![Crate](https://img.shields.io/crates/v/ructe.svg)](https://crates.io/crates/ructe)\n[![docs](https://docs.rs/ructe/badge.svg)](https://docs.rs/ructe)\n[![CI](https://github.com/kaj/ructe/workflows/CI/badge.svg)](https://github.com/kaj/ructe/actions)\n\n\n## Design criteria\n\n* As many errors as possible should be caught at compile-time.\n* A compiled binary should include all the template code it needs,\n  no need to read template files at runtime.\n* Compilation may take time, running should be fast.\n* Writing templates should be almost as easy as writing html.\n* The template language should be as expressive as possible.\n* It should be possible to write templates for any text-like format,\n  not only html.\n* Any value that implements the `Display` trait should be outputable.\n* By default, all values should be html-escaped.  There should be an\n  easy but explicit way to output preformatted html.\n\n## Current status\n\nRuctes is in a rather early stage, but does work;\ntemplates can be transpiled to rust functions, which are then compiled\nand can be called from rust code.\n\n### Template format\n\nA template consists of three basic parts:\nFirst a preamble of `use` statements, each prepended by an `@` sign.\nSecondly a declaration of the parameters the template takes.\nAnd third, the template body.\n\nThe full syntax is described [in the documentation](https://docs.rs/ructe/).\nSome examples can be seen in\n[examples/simple/templates](examples/simple/templates).\nA template may look something like this:\n\n```html\n@use any::rust::Type;\n@use super::statics::style_css;\n\n@(name: \u0026str, items: \u0026[Type])\n\n\u003chtml\u003e\n   \u003chead\u003e\n     \u003ctitle\u003e@name\u003c/title\u003e\n     \u003clink rel=\"stylesheet\" href=\"/static/@style_css.name\" type=\"text/css\"/\u003e\n   \u003c/head\u003e\n   \u003cbody\u003e\n     \u003ch1\u003e@name\u003c/h1\u003e\n     \u003cdl\u003e\n     @for item in items {\n       \u003cdt\u003e@item.title()\u003c/dt\u003e\n       \u003cdd\u003e@item.description()\u003c/dd\u003e\n     }\n     \u003c/dl\u003e\n   \u003cbody\u003e\n\u003c/html\u003e\n```\n\n## How to use ructe\n\nRucte compiles your templates to rust code that should be compiled with\nyour other rust code, so it needs to be called before compiling,\nas described [in the documentation](https://docs.rs/ructe/).\nThere are also [examples](examples),\nboth for ructe itself and its futures and for using it with the web\nframeworks [axum](examples/axum), [actix-web](examples/actix),\n[gotham](examples/gotham), [tide](examples/tide),\nand [warp](examples/warp03).\nThere is also [a separate example of using ructe with warp and\ndiesel](https://github.com/kaj/warp-diesel-ructe-sample).\n","funding_links":[],"categories":["Libraries","Rust","库 Libraries","库","Recently Updated"],"sub_categories":["Template engine","模板引擎 Template engine","模板引擎","[Mar 15, 2025](/content/2025/03/15/README.md)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaj%2Fructe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaj%2Fructe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaj%2Fructe/lists"}