{"id":16340735,"url":"https://github.com/casey/boilerplate","last_synced_at":"2025-04-09T16:20:59.106Z","repository":{"id":55829784,"uuid":"523254678","full_name":"casey/boilerplate","owner":"casey","description":"A statically-checked Rust Template Engine","archived":false,"fork":false,"pushed_at":"2024-08-17T21:55:31.000Z","size":96,"stargazers_count":68,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T16:20:42.410Z","etag":null,"topics":["rust","template-engine"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/casey.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING","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":"2022-08-10T08:04:37.000Z","updated_at":"2025-04-08T17:02:06.000Z","dependencies_parsed_at":"2023-12-08T01:32:07.858Z","dependency_job_id":"4aa3e16b-595f-426c-8d0b-1496bc313d58","html_url":"https://github.com/casey/boilerplate","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":"0.030303030303030276","last_synced_commit":"1a3d5b47cb34485ede0ec978019bf2d1c132aa84"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casey%2Fboilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casey%2Fboilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casey%2Fboilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casey%2Fboilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/casey","download_url":"https://codeload.github.com/casey/boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065287,"owners_count":21041872,"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":["rust","template-engine"],"created_at":"2024-10-10T23:57:41.549Z","updated_at":"2025-04-09T16:20:59.084Z","avatar_url":"https://github.com/casey.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\u003ccode\u003eboilerplate\u003c/code\u003e\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://crates.io/crates/boilerplate\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/v/boilerplate.svg\" alt=\"crates.io version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://docs.rs/boilerplate/latest/boilerplate/\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/v/boilerplate?color=blue\u0026label=docs\" alt=\"docs\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/casey/boilerplate/actions\"\u003e\n    \u003cimg src=\"https://github.com/casey/boilerplate/workflows/CI/badge.svg\" alt=\"ci status\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cbr\u003e\n\n`boilerplate` is a statically-checked Rust template engine with no runtime\ndependencies. There are two ways to use boilerplate,\n`boilerplate::boilerplate`, a function-like macro, and\n`boilerplate::Boilerplate`, a derive macro.\n\nFunction-like Macro\n-------------------\n\n```rust\nuse boilerplate::boilerplate;\n\nlet foo = true;\nlet bar: Result\u003c\u0026str, \u0026str\u003e = Ok(\"yassss\");\n\nlet output = boilerplate!(\n\"%% if foo {\nFoo was true!\n%% }\n%% match bar {\n%%   Ok(ok) =\u003e {\nPretty good: {{ ok }}\n%%   }\n%%   Err(err) =\u003e {\nNot so great: {{ err }}\n%%   }\n%% }\n\");\n\nassert_eq!(output, \"Foo was true!\\nPretty good: yassss\\n\");\n```\n\nDerive Macro\n------------\n\nDerive `Boilerplate` on the type you want to use as a template context:\n\n```rust\nuse boilerplate::Boilerplate;\n\n#[derive(Boilerplate)]\nstruct MyTemplateTxt {\n  foo: bool,\n  bar: Result\u003cString, Box\u003cdyn std::error::Error\u003e\u003e,\n}\n```\n\n`boilerplate` template code and interpolations are Rust, so errors are checked\nat compile time and the template language is easy to learn:\n\n```text\n%% if self.foo {\nFoo was true!\n%% }\n%% match \u0026self.bar {\n%%   Ok(ok) =\u003e {\nPretty good: {{ ok }}\n%%   }\n%%   Err(err) =\u003e {\nNot so great: {{ err }}\n%%   }\n%% }\n```\n\nThe `Boilerplate` macro provides a `Display` implementation, so you can\ninstantiate a template context and convert it to a string:\n\n```rust\nlet rendered = MyTemplateTxt { foo: true, bar: Ok(\"hello\".into()) }.to_string();\n```\n\nOr use it in a format string:\n\n```rust\nprintln!(\"The output is: {}\", MyTemplateTxt { foo: false, bar: Err(\"hello\".into()) });\n```\n\n`boilerplate`'s implementation is exceedingly simple. Try using\n[cargo-expand](https://github.com/dtolnay/cargo-expand) to expand the\n`Boilerplate` macro and inspect derived `Display` implementations and debug\ntemplate issues.\n\nQuick Start\n-----------\n\nAdd `boilerplate` to your project's `Cargo.toml`:\n\n```toml\n[dependencies]\nboilerplate = \"*\"\n```\n\nCreate a template in `templates/my-template.txt`:\n\n```text\nFoo is {{self.n}}!\n```\n\nDefine, instantiate, and render the template context:\n\n```rust\nuse boilerplate::Boilerplate;\n\n#[derive(Boilerplate)]\nstruct MyTemplateTxt {\n  n: u32,\n}\n\nassert_eq!(MyTemplateTxt  { n: 10 }.to_string(), \"Foo is 10!\\n\");\n```\n\nExamples\n--------\n\nSee [the docs](https://docs.rs/boilerplate/latest/boilerplate/) for more information and examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasey%2Fboilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcasey%2Fboilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasey%2Fboilerplate/lists"}