{"id":17718274,"url":"https://github.com/vidhanio/html-node","last_synced_at":"2025-04-10T05:23:59.167Z","repository":{"id":184090581,"uuid":"671300570","full_name":"vidhanio/html-node","owner":"vidhanio","description":"HTML nodes in Rust.","archived":false,"fork":false,"pushed_at":"2024-08-02T20:23:03.000Z","size":140,"stargazers_count":50,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-14T02:16:54.316Z","etag":null,"topics":["html","macro","macros","procedural-macros","rust","rust-lang"],"latest_commit_sha":null,"homepage":"https://docs.rs/html-node","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/vidhanio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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-07-27T02:34:25.000Z","updated_at":"2024-08-08T15:32:58.000Z","dependencies_parsed_at":"2024-01-12T07:59:58.251Z","dependency_job_id":"0907b158-4ce9-45bb-a366-2398a8479171","html_url":"https://github.com/vidhanio/html-node","commit_stats":null,"previous_names":["vidhanio/html-node"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vidhanio%2Fhtml-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vidhanio%2Fhtml-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vidhanio%2Fhtml-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vidhanio%2Fhtml-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vidhanio","download_url":"https://codeload.github.com/vidhanio/html-node/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161739,"owners_count":21057643,"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":["html","macro","macros","procedural-macros","rust","rust-lang"],"created_at":"2024-10-25T14:43:33.629Z","updated_at":"2025-04-10T05:23:59.143Z","avatar_url":"https://github.com/vidhanio.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `html-node`\n\nHTML nodes in Rust. \\[powered by [rstml](https://github.com/rs-tml/rstml)\\].\n\n## Note\n\nIf you want to use this purely for building websites in rust, consider using my other library, [hypertext](https://github.com/vidhanio/hypertext). It puts performance and type-checking first, and supports this crate's syntax as well as [maud](https://maud.lambda.xyz)'s syntax, which is much cleaner.\n\n## Features\n\n- Text escaping\n- Pretty-printing\n- Customizable compile-time type-checked elements and attributes ([docs](https://docs.rs/html-node/latest/html_node/typed/index.html))\n  - completely optional, and can be mixed with untyped elements when needed!\n\n## Example\n\n```rust\nlet shopping_list = vec![\"milk\", \"eggs\", \"bread\"];\n\nlet shopping_list_html = html! {\n    \u003cdiv\u003e\n        \u003ch1\u003eShopping List\u003c/h1\u003e\n        \u003cul\u003e\n            { shopping_list.into_iter().zip(1..).map(|(item, i)| html! {\n                \u003cli class=\"item\"\u003e\n                    \u003cinput type=\"checkbox\" id={format!(\"item-{i}\")}\u003e\n                    \u003clabel for={format!(\"item-{i}\")}\u003e{text!(\"{item}\")}\u003c/label\u003e\n                \u003c/li\u003e\n            }) }\n        \u003c/ul\u003e\n    \u003c/div\u003e\n};\n```\n\n\u003cdetails open\u003e\n\u003csummary\u003eHTML Output\u003c/summary\u003e\n\n```rust\n// the `#` flag enables pretty-printing\nprintln!(\"{shopping_list_html:#}\");\n```\n\n```html\n\u003cdiv\u003e\n    \u003ch1\u003e\n        Shopping List\n    \u003c/h1\u003e\n    \u003cul\u003e\n        \u003cli class=\"item\"\u003e\n            \u003cinput type=\"checkbox\" id=\"item-1\"\u003e\n            \u003clabel for=\"item-1\"\u003e\n                milk\n            \u003c/label\u003e\n        \u003c/li\u003e\n        \u003cli class=\"item\"\u003e\n            \u003cinput type=\"checkbox\" id=\"item-2\"\u003e\n            \u003clabel for=\"item-2\"\u003e\n                eggs\n            \u003c/label\u003e\n        \u003c/li\u003e\n        \u003cli class=\"item\"\u003e\n            \u003cinput type=\"checkbox\" id=\"item-3\"\u003e\n            \u003clabel for=\"item-3\"\u003e\n                bread\n            \u003c/label\u003e\n        \u003c/li\u003e\n    \u003c/ul\u003e\n\u003c/div\u003e\n```\n\n\u003c/details open\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eRust Output\u003c/summary\u003e\n\n```rust\nprintln!(\"{shopping_list_html:#?}\");\n```\n\n```rust\nElement(\n    Element {\n        name: \"div\",\n        attributes: [],\n        children: Some(\n            [\n                Element(\n                    Element {\n                        name: \"h1\",\n                        attributes: [],\n                        children: Some(\n                            [\n                                Text(\n                                    Text {\n                                        text: \"Shopping List\",\n                                    },\n                                ),\n                            ],\n                        ),\n                    },\n                ),\n                Element(\n                    Element {\n                        name: \"ul\",\n                        attributes: [],\n                        children: Some(\n                            [\n                                Fragment(\n                                    Fragment {\n                                        children: [\n                                            Element(\n                                                Element {\n                                                    name: \"li\",\n                                                    attributes: [\n                                                        (\n                                                            \"class\",\n                                                            Some(\n                                                                \"item\",\n                                                            ),\n                                                        ),\n                                                    ],\n                                                    children: Some(\n                                                        [\n                                                            Element(\n                                                                Element {\n                                                                    name: \"input\",\n                                                                    attributes: [\n                                                                        (\n                                                                            \"type\",\n                                                                            Some(\n                                                                                \"checkbox\",\n                                                                            ),\n                                                                        ),\n                                                                        (\n                                                                            \"id\",\n                                                                            Some(\n                                                                                \"item-1\",\n                                                                            ),\n                                                                        ),\n                                                                    ],\n                                                                    children: None,\n                                                                },\n                                                            ),\n                                                            Element(\n                                                                Element {\n                                                                    name: \"label\",\n                                                                    attributes: [\n                                                                        (\n                                                                            \"for\",\n                                                                            Some(\n                                                                                \"item-1\",\n                                                                            ),\n                                                                        ),\n                                                                    ],\n                                                                    children: Some(\n                                                                        [\n                                                                            Text(\n                                                                                Text {\n                                                                                    text: \"milk\",\n                                                                                },\n                                                                            ),\n                                                                        ],\n                                                                    ),\n                                                                },\n                                                            ),\n                                                        ],\n                                                    ),\n                                                },\n                                            ),\n                                            Element(\n                                                Element {\n                                                    name: \"li\",\n                                                    attributes: [\n                                                        (\n                                                            \"class\",\n                                                            Some(\n                                                                \"item\",\n                                                            ),\n                                                        ),\n                                                    ],\n                                                    children: Some(\n                                                        [\n                                                            Element(\n                                                                Element {\n                                                                    name: \"input\",\n                                                                    attributes: [\n                                                                        (\n                                                                            \"type\",\n                                                                            Some(\n                                                                                \"checkbox\",\n                                                                            ),\n                                                                        ),\n                                                                        (\n                                                                            \"id\",\n                                                                            Some(\n                                                                                \"item-2\",\n                                                                            ),\n                                                                        ),\n                                                                    ],\n                                                                    children: None,\n                                                                },\n                                                            ),\n                                                            Element(\n                                                                Element {\n                                                                    name: \"label\",\n                                                                    attributes: [\n                                                                        (\n                                                                            \"for\",\n                                                                            Some(\n                                                                                \"item-2\",\n                                                                            ),\n                                                                        ),\n                                                                    ],\n                                                                    children: Some(\n                                                                        [\n                                                                            Text(\n                                                                                Text {\n                                                                                    text: \"eggs\",\n                                                                                },\n                                                                            ),\n                                                                        ],\n                                                                    ),\n                                                                },\n                                                            ),\n                                                        ],\n                                                    ),\n                                                },\n                                            ),\n                                            Element(\n                                                Element {\n                                                    name: \"li\",\n                                                    attributes: [\n                                                        (\n                                                            \"class\",\n                                                            Some(\n                                                                \"item\",\n                                                            ),\n                                                        ),\n                                                    ],\n                                                    children: Some(\n                                                        [\n                                                            Element(\n                                                                Element {\n                                                                    name: \"input\",\n                                                                    attributes: [\n                                                                        (\n                                                                            \"type\",\n                                                                            Some(\n                                                                                \"checkbox\",\n                                                                            ),\n                                                                        ),\n                                                                        (\n                                                                            \"id\",\n                                                                            Some(\n                                                                                \"item-3\",\n                                                                            ),\n                                                                        ),\n                                                                    ],\n                                                                    children: None,\n                                                                },\n                                                            ),\n                                                            Element(\n                                                                Element {\n                                                                    name: \"label\",\n                                                                    attributes: [\n                                                                        (\n                                                                            \"for\",\n                                                                            Some(\n                                                                                \"item-3\",\n                                                                            ),\n                                                                        ),\n                                                                    ],\n                                                                    children: Some(\n                                                                        [\n                                                                            Text(\n                                                                                Text {\n                                                                                    text: \"bread\",\n                                                                                },\n                                                                            ),\n                                                                        ],\n                                                                    ),\n                                                                },\n                                                            ),\n                                                        ],\n                                                    ),\n                                                },\n                                            ),\n                                        ],\n                                    },\n                                ),\n                            ],\n                        ),\n                    },\n                ),\n            ],\n        ),\n    },\n)\n```\n\n\u003c/details open\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvidhanio%2Fhtml-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvidhanio%2Fhtml-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvidhanio%2Fhtml-node/lists"}