{"id":20114675,"url":"https://github.com/sebastienrousseau/staticweaver","last_synced_at":"2026-01-24T20:53:30.867Z","repository":{"id":258187096,"uuid":"873531106","full_name":"sebastienrousseau/staticweaver","owner":"sebastienrousseau","description":"A powerful and flexible static site generator and templating engine for Rust.","archived":false,"fork":false,"pushed_at":"2024-11-15T04:58:41.000Z","size":1324,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T22:49:31.265Z","etag":null,"topics":["dynamic-content","rust","rust-library","staticweaver","template","template-engine"],"latest_commit_sha":null,"homepage":"http://doc.staticweaver.com/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sebastienrousseau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/funding.yml","license":"LICENSE-APACHE","code_of_conduct":".github/CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sebastienrousseau","custom":"https://paypal.me/wwdseb"}},"created_at":"2024-10-16T10:21:10.000Z","updated_at":"2024-11-13T07:24:23.000Z","dependencies_parsed_at":"2024-10-17T23:59:24.197Z","dependency_job_id":"46c99846-067c-4a64-a656-bd9f717dbae0","html_url":"https://github.com/sebastienrousseau/staticweaver","commit_stats":null,"previous_names":["sebastienrousseau/staticweaver"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sebastienrousseau/staticweaver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastienrousseau%2Fstaticweaver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastienrousseau%2Fstaticweaver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastienrousseau%2Fstaticweaver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastienrousseau%2Fstaticweaver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebastienrousseau","download_url":"https://codeload.github.com/sebastienrousseau/staticweaver/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastienrousseau%2Fstaticweaver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28736791,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T19:23:36.361Z","status":"ssl_error","status_checked_at":"2026-01-24T19:23:28.966Z","response_time":89,"last_error":"SSL_read: 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":["dynamic-content","rust","rust-library","staticweaver","template","template-engine"],"created_at":"2024-11-13T18:31:14.240Z","updated_at":"2026-01-24T20:53:30.839Z","avatar_url":"https://github.com/sebastienrousseau.png","language":"Rust","funding_links":["https://github.com/sponsors/sebastienrousseau","https://paypal.me/wwdseb"],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable MD033 MD041 --\u003e\n\u003cimg src=\"https://kura.pro/staticweaver/images/logos/staticweaver.svg\"\nalt=\"StaticWeaver logo\" height=\"66\" align=\"right\" /\u003e\n\u003c!-- markdownlint-enable MD033 MD041 --\u003e\n\n# `StaticWeaver`\n\nA fast and flexible templating engine for Rust applications.\n\n\u003c!-- markdownlint-disable MD033 MD041 --\u003e\n\u003ccenter\u003e\n\u003c!-- markdownlint-enable MD033 MD041 --\u003e\n\n[![Made With Love][made-with-rust]][08] [![Crates.io][crates-badge]][03] [![lib.rs][libs-badge]][01] [![Docs.rs][docs-badge]][04] [![Codecov][codecov-badge]][06] [![Build Status][build-badge]][07] [![GitHub][github-badge]][09]\n\n• [Website][00] • [Documentation][04] • [Report Bug][02] • [Request Feature][02] • [Contributing Guidelines][05]\n\n\u003c!-- markdownlint-disable MD033 MD041 --\u003e\n\u003c/center\u003e\n\u003c!-- markdownlint-enable MD033 MD041 --\u003e\n\n## Overview\n\n`staticweaver` is a robust Rust library that provides a flexible and powerful templating engine. Designed for static site generation and more, it offers advanced caching, remote template support, and customizable rendering for optimized performance.\n\n## Features\n\n- **Flexible Template Rendering:** Ideal for static sites, web apps, and other use cases.\n- **Dynamic Content:** Easily interpolate variables in templates with a powerful context system.\n- **File and String Templates:** Render templates from both files and strings.\n- **Advanced Caching:** Improve performance by caching templates for repeated use.\n- **Custom Rendering:** Modify and extend the rendering process to fit your needs.\n- **Remote Template Support:** Fetch and render templates from URLs.\n- **Comprehensive Error Handling:** Gracefully manage template rendering errors.\n\n## Installation\n\nAdd `staticweaver` to your `Cargo.toml`:\n\n```toml\n[dependencies]\nstaticweaver = \"0.0.1\"\n```\n\n## Usage\n\nHere's a basic example of how to use `staticweaver`:\n\n```rust\nuse std::fs;\nuse staticweaver::engine::Engine;\nuse staticweaver::EngineError;\nuse staticweaver::error::TemplateError;\nuse staticweaver::context::Context;\nuse std::time::Duration;\nuse std::path::Path;\n\nfn main() -\u003e Result\u003c(), TemplateError\u003e {\n    // Create the 'examples' directory and 'template.html' for the test\n    fs::create_dir_all(\"examples\")?;\n    fs::write(\"examples/template.html\", r#\"\n    \u003c!DOCTYPE html\u003e\n    \u003chtml\u003e\n    \u003chead\u003e\u003ctitle\u003e{{title}}\u003c/title\u003e\u003c/head\u003e\n    \u003cbody\u003e\u003ch1\u003e{{title}}\u003c/h1\u003e\u003cp\u003e{{content}}\u003c/p\u003e\u003c/body\u003e\n    \u003c/html\u003e\"#)?;\n\n    // Create a new engine with a template path and cache duration\n    let mut engine = Engine::new(\"examples\", Duration::from_secs(60));\n\n    // Create a context with some variables\n    let mut context = Context::new();\n    context.set(\"title\".to_string(), \"Welcome to StaticWeaver\".to_string());\n    context.set(\"content\".to_string(), \"This is a simple example.\".to_string());\n\n    // Render the 'template.html', mapping EngineError to TemplateError\n    let rendered = engine\n        .render_page(\u0026context, \"template\")\n        .map_err(|e| TemplateError::EngineError(Box::new(EngineError::Render(format!(\"Rendering failed: {:?}\", e)))))?;\n\n    // Output the rendered content to 'rendered.html'\n    fs::write(\"examples/rendered.html\", \u0026rendered)?;\n\n    println!(\"Rendered content written to 'examples/rendered.html'.\");\n\n    // Clean up: remove files and directory\n    remove_dir_contents(\"examples\")?;\n\n    println!(\"Template and rendered files cleaned up.\");\n\n    Ok(())\n}\n\n// Helper function to remove all files inside a directory\nfn remove_dir_contents(dir: \u0026str) -\u003e std::io::Result\u003c()\u003e {\n    let path = Path::new(dir);\n    if path.is_dir() {\n        for entry in fs::read_dir(path)? {\n            let entry = entry?;\n            let entry_path = entry.path();\n            if entry_path.is_file() {\n                fs::remove_file(entry_path)?;\n            } else if entry_path.is_dir() {\n                fs::remove_dir_all(entry_path)?; // If there are subdirectories, remove them recursively\n            }\n        }\n        fs::remove_dir(path)?; // Finally, remove the directory itself\n    }\n    Ok(())\n}\n```\n\nThis example demonstrates rendering a template named \"page\", replacing `{{title}}` and `{{content}}` with values from the context.\n\n## Documentation\n\nFor full API documentation, please visit [docs.rs/staticweaver][04].\n\n## Examples\n\nTo explore more examples, clone the repository and run the following command:\n\n```shell\ncargo run --example example_name\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under either of\n\n- [Apache License, Version 2.0][10]\n- [MIT license][11]\n\nat your option.\n\n## Acknowledgements\n\nSpecial thanks to all contributors who have helped build the `staticweaver` library.\n\n[00]: https://staticweaver.com\n[01]: https://lib.rs/crates/staticweaver\n[02]: https://github.com/sebastienrousseau/staticweaver/issues\n[03]: https://crates.io/crates/staticweaver\n[04]: https://docs.rs/staticweaver\n[05]: https://github.com/sebastienrousseau/staticweaver/blob/main/CONTRIBUTING.md\n[06]: https://codecov.io/gh/sebastienrousseau/staticweaver\n[07]: https://github.com/sebastienrousseau/staticweaver/actions?query=branch%3Amain\n[08]: https://www.rust-lang.org/\n[09]: https://github.com/sebastienrousseau/staticweaver\n[10]: https://www.apache.org/licenses/LICENSE-2.0\n[11]: https://opensource.org/licenses/MIT\n\n[build-badge]: https://img.shields.io/github/actions/workflow/status/sebastienrousseau/staticweaver/release.yml?branch=main\u0026style=for-the-badge\u0026logo=github\n[codecov-badge]: https://img.shields.io/codecov/c/github/sebastienrousseau/staticweaver?style=for-the-badge\u0026token=psbZ8MASWj\u0026logo=codecov\n[crates-badge]: https://img.shields.io/crates/v/staticweaver.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\n[docs-badge]: https://img.shields.io/badge/docs.rs-staticweaver-66c2a5?style=for-the-badge\u0026labelColor=555555\u0026logo=docs.rs\n[github-badge]: https://img.shields.io/badge/github-sebastienrousseau/staticweaver-8da0cb?style=for-the-badge\u0026labelColor=555555\u0026logo=github\n[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.1-orange.svg?style=for-the-badge\n[made-with-rust]: https://img.shields.io/badge/rust-f04041?style=for-the-badge\u0026labelColor=c0282d\u0026logo=rust\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastienrousseau%2Fstaticweaver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebastienrousseau%2Fstaticweaver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastienrousseau%2Fstaticweaver/lists"}