{"id":19200316,"url":"https://github.com/lommix/templus","last_synced_at":"2026-06-15T02:33:07.101Z","repository":{"id":200058349,"uuid":"697509704","full_name":"Lommix/templus","owner":"Lommix","description":"Go inspired html template engine / compiler for rust","archived":false,"fork":false,"pushed_at":"2023-10-17T19:15:39.000Z","size":60,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-05T19:36:03.470Z","etag":null,"topics":["html","rust","template","templates","web"],"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/Lommix.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-27T22:01:53.000Z","updated_at":"2025-02-03T10:58:28.000Z","dependencies_parsed_at":"2024-11-09T12:34:39.735Z","dependency_job_id":"54fa1e7b-cb88-4e18-9599-8c0e416794ef","html_url":"https://github.com/Lommix/templus","commit_stats":null,"previous_names":["lommix/templus"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Lommix/templus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lommix%2Ftemplus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lommix%2Ftemplus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lommix%2Ftemplus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lommix%2Ftemplus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lommix","download_url":"https://codeload.github.com/Lommix/templus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lommix%2Ftemplus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34345577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["html","rust","template","templates","web"],"created_at":"2024-11-09T12:32:00.976Z","updated_at":"2026-06-15T02:33:07.059Z","avatar_url":"https://github.com/Lommix.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Templus\n\n### Go inspired template engine/compiler for Rust.\n\nWith proper inheritance, composition and caching.\n\n---\n\nRecently, I had the opportunity to develop a small web app in Go utilizing solely the standard libraries.\nIt is truly remarkable how comprehensive the Go standard library ecosystem is and how far you get with no dependencies at all.\n\nThe template behavior was the only truly frustrating aspect for me.\nThe syntax is acceptable, but the inability to parse all my templates simultaneously, cache the parse tree, and then render specific blocks while maintaining inheritance and composition is disappointing.\nImporting items multiple times results in overwrites, and a template can only be inherited once. Go necessitates parsing all required templates for each page in a separate object or reprocessing them with each request.\n\nTo challenge myself I implemented my own Go inspired template engine in rust with `serde` being the only dependency.\nSyntax is basically the same, but with proper `if` statements, inheritance, and composition.\n\nThis is work in progress and will probably be used and iterated on in my next small web project.\n\n```bash\ncargo run --example render\n```\n\n## Basic Example\n\nTemplates are defined by blocks. You can have as many as you want in one file. Html outside define-blocks is ignored.\nThere is very little cloning, the template container is bound to the lifetime of the template source. Only in the final\nrender step, the Html gets copied to new Memory. This should make things pretty fast.\n\n```rust\nlet tmpl = std::fs::read_to_string(\"templus/examples/example.html\").expect(\"cannot read file\");\n\nlet mut envirement = templus::renderer::Envirement::new();\nenvirement.parse(\u0026tmpl).unwrap();\n\nlet html = environment\n    .render(\n        \"foo\",\n        \u0026templus::context! {\n            name =\u003e \"lommix\",\n            number =\u003e 69,\n            bool =\u003e true\n        },\n    )\n    .unwrap();\n\nprint!(\"{}\", html);\n```\n\nSample template code:\n```html\n{{ define 'base' }}\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003cmeta charset=\"UTF-8\" /\u003e\n        {{block 'meta'}}\n        {{ end }}\n    \u003c/head\u003e\n    \u003cbody\u003e\n        {{ block 'content' }}\n        {{ end }}\n        {{ block 'js' }}\n            \u003cscript src=\"/test.js\"\u003e\u003c/script\u003e\n        {{ end }}\n    \u003c/body\u003e\n\u003c/html\u003e\n{{ end }}\n\n{{ define 'foo' extends 'base' }}\n\n    {{ block 'meta' }}\n        \u003ctitle\u003ejsx sucks\u003c/title\u003e\n    {{end}}\n\n    {{ block 'content' }}\n        \u003ch1\u003ehello\u003c/h1\u003e\n\n        \u003cdiv class=\"import-this\"\u003e\n            {{ import 'foobar' }}\n        \u003c/div\u003e\n\n        {{ if .bool }}\n            \u003cp\u003ebool is true\u003c/p\u003e\n        {{end}}\n\n        {{ if .number \u003e 42 }}\n            \u003cp\u003enum is bigger than 42\u003c/p\u003e\n        {{ end }}\n\n        {{ if .number \u003c 42 }}\n            \u003cp\u003enum is smaller than 42\u003c/p\u003e\n        {{ else }}\n            \u003cp\u003enum is not smaller than 42\u003c/p\u003e\n        {{ end }}\n\n        {{ if .number == 69 }}\n            \u003cp\u003enumber is 69\u003c/p\u003e\n        {{ end }}\n\n    {{ end }}\n{{ end }}\n\n{{ define 'foobar'}}\n    \u003cul class=\"loop-example\"\u003e\n    {{ range 10 }}\n        \u003cli\u003e you are {{.name}} \u003c/li\u003e\n    {{ end }}\n    \u003c/ul\u003e\n{{ end }}\n```\n\n## Todos\n\n- Variable assignments.\n- Binary operators in if statements.\n- User defined functions.\n- Bindings for other languages.\n- Cli Tools and Parse Tree serialization.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flommix%2Ftemplus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flommix%2Ftemplus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flommix%2Ftemplus/lists"}