{"id":16116657,"url":"https://github.com/dpc/stpl","last_synced_at":"2025-09-26T10:31:32.204Z","repository":{"id":57668754,"uuid":"112952995","full_name":"dpc/stpl","owner":"dpc","description":"Super templates (html, etc.) with plain-Rust; no macros, no textfiles","archived":false,"fork":false,"pushed_at":"2018-07-20T04:36:36.000Z","size":47,"stargazers_count":37,"open_issues_count":1,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-09T23:38:06.024Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dpc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-03T18:35:53.000Z","updated_at":"2024-02-21T01:17:05.000Z","dependencies_parsed_at":"2022-08-27T03:50:28.272Z","dependency_job_id":null,"html_url":"https://github.com/dpc/stpl","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpc%2Fstpl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpc%2Fstpl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpc%2Fstpl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpc%2Fstpl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dpc","download_url":"https://codeload.github.com/dpc/stpl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234304792,"owners_count":18811257,"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":[],"created_at":"2024-10-09T20:25:11.967Z","updated_at":"2025-09-26T10:31:31.909Z","avatar_url":"https://github.com/dpc.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- README.md is auto-generated from README.tpl with `cargo readme` --\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://travis-ci.org/dpc/stpl\"\u003e\n      \u003cimg src=\"https://img.shields.io/travis/dpc/stpl/master.svg?style=flat-square\" alt=\"Travis CI Build Status\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://crates.io/crates/stpl\"\u003e\n      \u003cimg src=\"http://meritbadge.herokuapp.com/stpl?style=flat-square\" alt=\"crates.io\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://gitter.im/dpc/stpl\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/GITTER-join%20chat-green.svg?style=flat-square\" alt=\"Gitter Chat\"\u003e\n  \u003c/a\u003e\n  \u003cbr\u003e\n\u003c/p\u003e\n\n# stpl\n\n### stpl - Super template library for Rust\n\n`stpl` is a plain-Rust-only template library with some neat properties and\nfeatures.\n\n### Main idea\n\nIn `stpl` there are no magic macros or DSLs, and no clunky\ntext-files with weird syntax. Everything is just normal, easy\nto understand Rust code.\n\nLet's take a look at a real-life example from the pilot project: an HTML\nbased-skeleton template for a Bootstrap-based UI.\n\n```rust\npub fn base\u003cC: Render + 'static\u003e(data: \u0026Data, content: C) -\u003e impl Render {\n    (\n        doctype(\"html\"),\n        html((\n            head((\n                meta.charset(\"utf-8\"),\n                meta.name(\"viewport\").content(\"width=device-width, initial-scale=1, shrink-to-fit=no\"),\n                meta.name(\"description\").content(\"\"),\n                meta.name(\"author\").content(\"Dawid Ciężarkiewicz\"),\n                title(data.title.clone()),\n                (\n                    link.rel(\"icon\").href(\"/static/favicon.ico\"),\n                    link.rel(\"stylesheet\").href(\"/static/theme/flatly/bootstrap.min.css\"),\n                    link.rel(\"stylesheet\").href(\"/static/theme/starter-template.css\"),\n                )\n            )),\n            body((\n                navbar(data),\n                main\n                    .id(\"main\")\n                    .role(\"main\")\n                    .class(\"container mb-5\")(\n                    content,\n                ),\n                (\n                script.src(\"https://code.jquery.com/jquery-3.2.1.min.js\").crossorigin(\"anonymous\"),\n                script.src(\"https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js\")\n                    .integrity(\"sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh\")\n                    .crossorigin(\"anonymous\"),\n                script.src(\"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js\")\n                    .integrity(\"sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ\")\n                    .crossorigin(\"anonymous\"),\n                script.type_(\"text/javascript\")(\n                    raw(include_str!(\"white-icon.js\"))\n                ),\n                )\n            ))\n        ))\n    )\n}\n```\n\nIt is just a function. There is no magic, no macros, no text files involved.\nThe whole template was formatted with `rustfmt` just like a normal Rust code.\n\nThe function accepts arguments:\n\n* `data: Data` containing information how to \"fill the blanks\", and\n* `content: Render` - sub-template value that will be used as main page content.\n\nThe function returns `Render` value that can be rendered as a string or bytes, or\ncomposed with other templates. The value is basically a one big tuple\nnesting many other `Render` values. `Render` is implemented for many standard types,\ncan be implemented for new types or can be generated using functions/closures.\n\nUsers are free to use any Rust language primitives to generate their\ntemplates and structure relationship between them in any way that\nsuits them.\n\n### Pros\n\n* robust: template generation can reuse any existing code and data\n  structures\n* convenient: Rust tooling can work with plain-Rust-templates just\n  like any other code; `rustfmt` takes care of formatting, typos result\n  in normal error messages etc.\n* fast: the compiler optimizes the template code to essential logic\n  necessary to write-out the rendered template data to the IO; there\n  is no parsing involved\n\n### Cons\n\n* `nightly`-only: This library relies on some unstable features:\n   * `#![feature(unboxed_closures)]`\n   # `![feature(fn_traits)]`\n* immature and incomplete: This library is still work in progress, and will\n  mature with time.\n\n## Where to start\n\nYou are most probably interested in reading `html` module documentation\n\n# License\n\nstpl is licensed under: MPL-2.0/MIT/Apache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpc%2Fstpl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdpc%2Fstpl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpc%2Fstpl/lists"}