{"id":15651589,"url":"https://github.com/shekohex/sigma","last_synced_at":"2025-04-30T17:11:28.621Z","repository":{"id":57667326,"uuid":"164751841","full_name":"shekohex/sigma","owner":"shekohex","description":"Sigma σ is a Simple, Safe and Fast Template language","archived":false,"fork":false,"pushed_at":"2019-01-14T21:01:39.000Z","size":45,"stargazers_count":32,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-30T17:11:25.600Z","etag":null,"topics":["rust-library","template-language"],"latest_commit_sha":null,"homepage":null,"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/shekohex.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}},"created_at":"2019-01-08T23:45:37.000Z","updated_at":"2024-08-07T14:58:59.000Z","dependencies_parsed_at":"2022-09-02T14:01:28.235Z","dependency_job_id":null,"html_url":"https://github.com/shekohex/sigma","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekohex%2Fsigma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekohex%2Fsigma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekohex%2Fsigma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekohex%2Fsigma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shekohex","download_url":"https://codeload.github.com/shekohex/sigma/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251748950,"owners_count":21637418,"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-library","template-language"],"created_at":"2024-10-03T12:39:13.657Z","updated_at":"2025-04-30T17:11:28.599Z","avatar_url":"https://github.com/shekohex.png","language":"Rust","readme":"# Sigma σ is a Simple, Safe and Fast Template language\n\n[![Latest version](https://img.shields.io/crates/v/sigma.svg)](https://crates.io/crates/sigma)\n[![Documentation](https://docs.rs/sigma/badge.svg)](https://docs.rs/sigma)\n![License](https://img.shields.io/crates/l/sigma.svg)\n\nHi {{ name }} i'm sigma :wave: !\n\n##### Simple:\nsigma is a very simple template language, it only tries to solve only one\nproblem. it also extendable, but with simple idea too (_Pure Functions_).\n##### Safe:\nsigma is also typed, that means that it has the idea of built-in validators\nfor your input. and for those how wanna play, it also could be untyped.\nalso it has a good error checking at parse time of your template.\nthe only error that could happen in runtime is that the input data fails to be parsed to your data types\nin your templates.\n\nHere is some error examples:\n```\n--\u003e 1:49\n  |\n1 | my username is {{ username: str |\u003e UPPERCASE |\u003e NO_FUN }} WOW!\n  |                                                 ^----^\n  |\n  = undefined function: NO_FUN\n```\nwhat if you forgot to bind for some variable in your template ?\n```\n --\u003e 1:19\n  |\n1 | my username is {{ username: str |\u003e UPPERCASE |\u003e NO_FUN }} WOW!\n  |                   ^------^\n  |\n  = undefined variable: username consider adding a bind for it\n```\ndo you need extra help ? we got your back ;)\n```\n--\u003e 1:35\n  |\n1 | my username is {{ username: u32 | UPPERCAS }} WOW!\n  |                                   ^------^\n  |\n  = undefined function: UPPERCAS did you mean: UPPERCASE ?\n```\n\n##### Fast:\nsigma uses [`pest`](https://pest.rs/), The Elegant Parser under the hood to write it's grammar.\nthat means it will be exteramly fast in parsing your templete, also it uses regex crate to replace your\ndata in the template.\n\nHere is some benchmacrk on my old pc running intel quad core q9650 processor and an Hard Disk Drive (HDD)\n```\nsmall_data_1kb_parse: 55.300 us\nsmall_data_10kb_parse: 516.29 us\nsmall_data_50kb_parse: 2.5659 ms\nsmall_data_500kb_parse: 25.467 ms\nsmall_data_1mb_parse: 48.668 ms\n---\nsmall_data_1kb_compile: 123.39 us\nsmall_data_10kb_compile: 120.90 us\nsmall_data_50kb_compile: 255.70 us\nsmall_data_500kb_compile: 1.4492 ms\nsmall_data_1mb_compile: 1.1464 ms\n```\n\n### Examples\nhere is a simple examples of how it works\n\n* Simple:\n```rust\nuse sigma::Sigma;\nlet result = Sigma::new(\"Hello {{ username }}\") // using {{ ... }} for the template.\n .bind(\"username\", \"someone\") // bind the vars with values\n .parse() // you must parse your template first\n .map_err(|e| eprintln!(\"{}\", e))? // for pretty printing the error..\n .compile()?;\nassert_eq!(\"Hello someone\", result);\n```\n* with optinal variables\n```rust\nuse sigma::Sigma;\n  \nlet result = Sigma::new(\"Hello {{ username? }}\") // using `?` to tell the parser it maybe `null`.\n .parse()\n .map_err(|e| eprintln!(\"{}\", e))? // for pretty printing the error..\n .compile()?;\nassert_eq!(\"Hello \", result);\n```\n* what about types ?\n```rust\nuse sigma::Sigma;\n  \nlet result = Sigma::new(\"Hello {{ username: str }}\") // u8, u32 ? a bool ?.\n .bind(\"username\", \"someone\")\n .parse()\n .map_err(|e| eprintln!(\"{}\", e))? // for pretty printing the error..\n .compile()?;\nassert_eq!(\"Hello someone\", result);\n```\n* how about functions ?\n```rust\nuse sigma::Sigma;\n  \nlet result = Sigma::new(\"Hello {{ username: str | UPPERCASE }}\") // functions uses the `|` operator or if you love `|\u003e` you can use it too.\n .bind(\"username\", \"someone\")\n .parse()\n .map_err(|e| eprintln!(\"{}\", e))? // for pretty printing the error..\n .compile()?;\nassert_eq!(\"Hello SOMEONE\", result);\n```\n* love macros ?\n```rust\nuse sigma::sigma;\nlet username = \"someone\";\nlet result = sigma!(\"Hello {{ username }}\", username); // the macro return the result so you can check for compile erros.\nassert_eq!(\"Hello someone\", result.unwrap());\n```\n\n## Contributing\n\nYou are welcome to contribute to this project, just open a PR.\n\n## Authors\n\n* **Shady Khalifa** - _Initial work_\n\nSee also the list of [contributors](https://github.com/shekohex/sigma/contributors) who participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshekohex%2Fsigma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshekohex%2Fsigma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshekohex%2Fsigma/lists"}