{"id":13503121,"url":"https://github.com/fiji-flo/gtmpl-rust","last_synced_at":"2026-04-08T13:31:08.273Z","repository":{"id":48105650,"uuid":"88834155","full_name":"fiji-flo/gtmpl-rust","owner":"fiji-flo","description":"golang text/template for rust","archived":false,"fork":false,"pushed_at":"2022-03-30T18:06:34.000Z","size":238,"stargazers_count":90,"open_issues_count":7,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-03-12T23:26:45.621Z","etag":null,"topics":["golang-template","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fiji-flo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-20T07:26:53.000Z","updated_at":"2026-03-10T13:25:42.000Z","dependencies_parsed_at":"2022-08-12T18:40:51.335Z","dependency_job_id":null,"html_url":"https://github.com/fiji-flo/gtmpl-rust","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fiji-flo/gtmpl-rust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiji-flo%2Fgtmpl-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiji-flo%2Fgtmpl-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiji-flo%2Fgtmpl-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiji-flo%2Fgtmpl-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fiji-flo","download_url":"https://codeload.github.com/fiji-flo/gtmpl-rust/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiji-flo%2Fgtmpl-rust/sbom","scorecard":{"id":399258,"data":{"date":"2025-08-11","repo":{"name":"github.com/fiji-flo/gtmpl-rust","commit":"3125cd374e5d2dfade8bb365898493f60797a6dd"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/rust.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 2/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/rust.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/fiji-flo/gtmpl-rust/rust.yml/master?enable=pin","Info:   0 out of   1 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 11 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T19:44:35.908Z","repository_id":48105650,"created_at":"2025-08-18T19:44:35.908Z","updated_at":"2025-08-18T19:44:35.908Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31558379,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T10:21:54.569Z","status":"ssl_error","status_checked_at":"2026-04-08T10:21:38.171Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["golang-template","rust","template-engine"],"created_at":"2024-07-31T22:02:37.921Z","updated_at":"2026-04-08T13:31:08.243Z","avatar_url":"https://github.com/fiji-flo.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# gtmpl-rust – Golang Templates for Rust\n\n[![Latest Version]][crates.io]\n\n[Latest Version]: https://img.shields.io/crates/v/gtmpl.svg\n[crates.io]: https://crates.io/crates/gtmpl\n\n---\n\n[gtmpl-rust] provides the [Golang text/template] engine for Rust. This enables\nseamless integration of Rust application into the world of devops tools around\n[kubernetes], [docker] and whatnot.\n\n## Getting Started\n\nAdd the following dependency to your Cargo manifest…\n```toml\n[dependencies]\ngtmpl = \"0.7\"\n```\n\nand look at the docs:\n* [gtmpl at crates.io](https://crates.io/crates/gtmpl)\n* [gtmpl documentation](https://docs.rs/crate/gtmpl)\n* [golang documentation](https://golang.org/pkg/text/template/)\n\n\nIt's not perfect, yet. Help and feedback is more than welcome.\n\n## Some Examples\n\nBasic template:\n```rust\nuse gtmpl;\n\nfn main() {\n    let output = gtmpl::template(\"Finally! Some {{ . }} for Rust\", \"gtmpl\");\n    assert_eq!(\u0026output.unwrap(), \"Finally! Some gtmpl for Rust\");\n}\n```\n\nAdding custom functions:\n```rust\nuse gtmpl_value::Function;\nuse gtmpl::{FuncError, gtmpl_fn, template, Value};\n\nfn main() {\n    gtmpl_fn!(\n    fn add(a: u64, b: u64) -\u003e Result\u003cu64, FuncError\u003e {\n        Ok(a + b)\n    });\n    let equal = template(r#\"{{ call . 1 2 }}\"#, Value::Function(Function { f: add }));\n    assert_eq!(\u0026equal.unwrap(), \"3\");\n}\n```\n\nPassing a struct as context:\n```rust\nuse gtmpl_derive::Gtmpl;\n\n#[derive(Gtmpl)]\nstruct Foo {\n    bar: u8\n}\n\nfn main() {\n    let foo = Foo { bar: 42 };\n    let output = gtmpl::template(\"The answer is: {{ .bar }}\", foo);\n    assert_eq!(\u0026output.unwrap(), \"The answer is: 42\");\n}\n```\n\nInvoking a *method* on a context:\n```rust\n\nuse gtmpl_derive::Gtmpl;\nuse gtmpl::{Func, FuncError, Value};\n\nfn plus_one(args: \u0026[Value]) -\u003e Result\u003cValue, FuncError\u003e {\n    if let Value::Object(ref o) = \u0026args[0] {\n        if let Some(Value::Number(ref n)) = o.get(\"num\") {\n            if let Some(i) = n.as_i64() {\n                return Ok((i +1).into())\n            }\n        }\n    }\n    Err(anyhow!(\"integer required, got: {:?}\", args))\n}\n\n#[derive(Gtmpl)]\nstruct AddMe {\n    num: u8,\n    plus_one: Func\n}\n\nfn main() {\n    let add_me = AddMe { num: 42, plus_one };\n    let output = gtmpl::template(\"The answer is: {{ .plus_one }}\", add_me);\n    assert_eq!(\u0026output.unwrap(), \"The answer is: 43\");\n}\n```\n\n## Current Limitations\n\nThis is work in progress. Currently the following features are not supported:\n\n* complex numbers\n* the following functions have not been implemented:\n  * `html`, `js`\n* `printf` is not yet fully stable, but should support all *sane* input\n\n## Enhancements\n\nEven though it was never intended to extend the syntax of Golang text/template\nthere might be some convenient additions:\n\n### Dynamic Template\n\nEnable `gtmpl_dynamic_template` in your `Cargo.toml`:\n```toml\n[dependencies.gtmpl]\nversion = \"0.7\"\nfeatures = [\"gtmpl_dynamic_template\"]\n\n```\n\nNow you can have dynamic template names for the `template` action.\n\n#### Example\n\n```rust\nuse gtmpl::{Context, Template};\n\nfn main() {\n    let mut template = Template::default();\n    template\n        .parse(\n            r#\"\n            {{- define \"tmpl1\"}} some {{ end -}}\n            {{- define \"tmpl2\"}} some other {{ end -}}\n            there is {{- template (.) -}} template\n            \"#,\n        )\n        .unwrap();\n\n    let context = Context::from(\"tmpl2\");\n\n    let output = template.render(\u0026context);\n    assert_eq!(output.unwrap(), \"there is some other template\".to_string());\n}\n```\n\nThe following syntax is used:\n```\n{{template (pipeline)}}\n\tThe template with the name evaluated from the pipeline (parenthesized) is\n    executed with nil data.\n\n{{template (pipeline) pipeline}}\n\tThe template with the name evaluated from the first pipeline (parenthesized)\n    is executed with dot set to the value of the second pipeline.\n```\n\n## Context\n\nWe use [gtmpl_value]'s Value as internal data type. [gtmpl_derive] provides a\nhandy `derive` macro to generate the `From` implementation for `Value`.\n\nSee:\n\n* [gtmpl_value at crates.io](https://crates.io/crate/gtmpl_value)\n* [gtmpl_value documentation](https://docs.rs/crate/gtmpl_value)\n* [gtmpl_derive at crates.io](https://crates.io/crate/gtmpl_derive)\n* [gtmpl_derive documentation](https://docs.rs/crate/gtmpl_derive)\n\n## Why do we need this?\n\nWhy? Dear god, why? I can already imagine the question coming up why anyone would\never do this. I wasn't a big fan of Golang templates when i first had to write\nsome custom formatting strings for **docker**. Learning a new template language\nusually isn't something one is looking forward to. Most people avoid it\ncompletely. However, it's really useful for automation if you're looking for\nsomething more lightweight than a full blown DSL.\n\nThe main motivation for this is to make it easier to write devops tools in Rust\nthat feel native. [docker] and [helm] ([kubernetes]) use golang templates and\nit feels more native if tooling around them uses the same.\n\n[gtmpl-rust]: https://github.com/fiji-flo/gtmpl-rust\n[Golang text/template]: https://golang.org/pkg/text/template/\n[kubernetes]: https://kubernetes.io\n[helm]: https://github.com/kubernetes/helm/blob/master/docs/chart_best_practices/templates.md\n[docker]: https://docker.com\n[gtmpl_value]: https://github.com/fiji-flo/gtmpl_value\n[gtmpl_derive]: https://github.com/fiji-flo/gtmpl_derive\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiji-flo%2Fgtmpl-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffiji-flo%2Fgtmpl-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiji-flo%2Fgtmpl-rust/lists"}