Commit ef49a23
More templating
Changed files (4)
modifiedkaja-web-template/Cargo.tomlmodifiedkaja-web-template/index.htmlmodifiedkaja-web-template/run.ps1modifiedkaja-web-template/src/lib.rs
Diff
@@ -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"] }@@ -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>@@ -6,6 +6,4 @@ if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } -Start-Process "http://localhost:8000"- python -m http.server 8000@@ -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(); }