{"id":16011282,"url":"https://github.com/sof3/defy","last_synced_at":"2025-03-17T20:31:25.939Z","repository":{"id":85794717,"uuid":"606700091","full_name":"SOF3/defy","owner":"SOF3","description":"Replacement for the `yew::html!` macro with more Rust-idiomatic, editor-friendly syntax.","archived":false,"fork":false,"pushed_at":"2023-09-30T03:59:06.000Z","size":31,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T04:08:02.228Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/SOF3.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-02-26T09:49:08.000Z","updated_at":"2023-06-08T20:58:05.000Z","dependencies_parsed_at":"2023-03-07T21:45:23.614Z","dependency_job_id":"747d084e-b147-4aed-9d2b-3163bbaf9381","html_url":"https://github.com/SOF3/defy","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"fbd50d75c2bfe66c5361e3df9c72ea846e7f3060"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SOF3%2Fdefy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SOF3%2Fdefy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SOF3%2Fdefy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SOF3%2Fdefy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SOF3","download_url":"https://codeload.github.com/SOF3/defy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243882240,"owners_count":20363109,"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-08T13:41:27.251Z","updated_at":"2025-03-17T20:31:25.614Z","avatar_url":"https://github.com/SOF3.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# defy\n\n[![GitHub actions](https://github.com/SOF3/defy/workflows/CI/badge.svg)](https://github.com/SOF3/defy/actions?query=workflow%3ACI)\n[![crates.io](https://img.shields.io/crates/v/defy.svg)](https://crates.io/crates/defy)\n[![crates.io](https://img.shields.io/crates/d/defy.svg)](https://crates.io/crates/defy)\n[![docs.rs](https://docs.rs/defy/badge.svg)](https://docs.rs/defy)\n[![GitHub](https://img.shields.io/github/last-commit/SOF3/defy)](https://github.com/SOF3/defy)\n[![GitHub](https://img.shields.io/github/stars/SOF3/defy?style=social)](https://github.com/SOF3/defy)\n\nReplacement for the [`yew::html!` macro](https://docs.rs/yew/latest/yew/macro.html.html)\nwith more Rust-idiomatic, editor-friendly syntax.\n\nThe syntax used in this crate is largely inspired by\n[kotlinx.html](https://github.com/Kotlin/kotlinx.html) and\n[horrorshow](https://docs.rs/horrorshow).\n\n## Example\n\n```rust\nuse defy::defy;\n\nstruct Datum {\n    field:   \u0026'static str,\n    display: bool,\n    label:   Label,\n}\nenum Label {\n    First(i32),\n    Second(u64),\n}\nlet data = vec![\n    Datum { field: \"foo\", display: false, label: Label::First(1) },\n    Datum { field: \"bar\", display: true, label: Label::Second(2) },\n];\n\nlet vnode = defy! {\n    h1 {\n        + \"Hello world\";\n    }\n    ul {\n        for datum in data {\n            let field = datum.field;\n            if datum.display {\n                li(data-length = field.len().to_string()) {\n                    + field;\n                }\n            }\n            match datum.label {\n                Label::First(i) if i \u003e 3 =\u003e {\n                    h2 { +i; }\n                }\n                Label::Second(i) =\u003e {\n                    h3 { +i; }\n                }\n                _ =\u003e { +\"unmatched\"; }\n            }\n        }\n    }\n};\n\n// Rendering code omitted\nassert_eq!(\n    vnode_html.as_str().replace(['\\n', ' '], \"\"),\n    r#\"\n        \u003ch1\u003eHello world\u003c/h1\u003e\n        \u003cul\u003e\n            unmatched\n            \u003cli data-length=\"3\"\u003ebar\u003c/li\u003e\n            \u003ch3\u003e2\u003c/h3\u003e\n        \u003c/ul\u003e\n    \"#\n    .replace(['\\n', ' '], \"\")\n);\n```\n\n## Why invent another syntax?\n\nYew already provides several editor plugins\nto help make editors treat `html!` blocks as HTML syntax.\nHowever the editor covergae is not complete,\nand interacts weirdly with normal Rust syntax.\n`defy` uses a syntax that resembles the normal Rust syntax\n(a similar idea as [ron](https://github.com/ron-rs/ron))\nand provides better syntactic sugar for constructs like for loops.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsof3%2Fdefy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsof3%2Fdefy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsof3%2Fdefy/lists"}