Clone in a terminal:
Commit ef49a23
Johan Mattsson - 2026-10-31T22:48:27+00:00
ef49a230f487278277dbafd397c82b3c8968752cjohan.mattsson.m@gmail.com

More templating

Changed files (4)

Diff

diff --git a/kaja-web-template/Cargo.toml b/kaja-web-template/Cargo.tomlindex 14bc1cd..a853fdc 100644--- a/kaja-web-template/Cargo.toml+++ b/kaja-web-template/Cargo.toml@@ -8,5 +8,9 @@ description = "{{description}}" crate-type = ["cdylib"]  [dependencies]-kaja-web = "1.0"+kaja-web = "=1.0.3" wasm-bindgen = "0.2"+gloo = "0.12"+inventory = "0.3"+js-sys = "0.3"+web-sys = { version = "0.3", features = ["Element", "HtmlElement", "NodeList", "CustomElementRegistry", "ElementDefinitionOptions"] }diff --git a/kaja-web-template/index.html b/kaja-web-template/index.htmlindex bb6511d..255984e 100644--- a/kaja-web-template/index.html+++ b/kaja-web-template/index.html@@ -4,11 +4,13 @@     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1">     <title>{{project-name}}</title>-</head>-<body>+     <script type="module">         import init from "./pkg/{{crate_name}}.js";         await init();     </script>+</head>+<body>+    <hello-card></hello-card> </body> </html>diff --git a/kaja-web-template/run.ps1 b/kaja-web-template/run.ps1index 4eed182..9a3ec21 100644--- a/kaja-web-template/run.ps1+++ b/kaja-web-template/run.ps1@@ -6,6 +6,4 @@ if ($LASTEXITCODE -ne 0) {     exit $LASTEXITCODE } -Start-Process "http://localhost:8000"- python -m http.server 8000diff --git a/kaja-web-template/src/lib.rs b/kaja-web-template/src/lib.rsindex 3f4778d..a34f6cc 100644--- a/kaja-web-template/src/lib.rs+++ b/kaja-web-template/src/lib.rs@@ -1,7 +1,21 @@-use wasm_bindgen::prelude::*; use kaja_web::prelude::*; +#[component("hello-card")]+struct HelloCard;++impl Component for HelloCardComponent {+    fn connected(&self) {+        let content = html! {{+            <strong>Hello from Rust!</strong>+        }};++        if let Some(element) = get_element_by_id(&self.get_id()) {+            element.set_inner_html(content.as_str());+        }+    }+}+ #[wasm_bindgen(start)] pub fn main() {-    // Your application starts here.+    init_callbacks(); }

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112