Commit c790785
Test for include tag
Changed files (5)
modifiedtest-fail-messages/include/Cargo.lockmodifiedtest-fail-messages/include/Cargo.tomlmodifiedtest-fail-messages/start/Cargo.tomlmodifiedtest-fail-messages/structmember/Cargo.tomladdedtests/include.rs
Diff
@@ -3,21 +3,20 @@ version = 4 [[package]]-name = "htmlmacro"+name = "include" version = "0.1.0" dependencies = [- "proc-macro-error",- "proc-macro2",- "quote",- "syn 2.0.111",- "v_htmlescape",+ "kaja-html-macro", ] [[package]]-name = "include"-version = "0.1.0"+name = "kaja-html-macro"+version = "1.0.2" dependencies = [- "htmlmacro",+ "proc-macro-error",+ "proc-macro2",+ "quote",+ "syn 2.0.111", ] [[package]]@@ -90,12 +89,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]]-name = "v_htmlescape"-version = "0.15.8"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "4e8257fbc510f0a46eb602c10215901938b5c2a7d5e70fc11483b1d3c9b5b18c"--[[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index"@@ -6,7 +6,7 @@ version = "0.1.0" edition = "2024" [dependencies]-htmlmacro = { path = "../../" }+kaja-html-macro = { path = "../../" } [[bin]] name = "include"@@ -6,7 +6,7 @@ version = "0.1.0" edition = "2024" [dependencies]-htmlmacro = { path = "../../" }+kaja-html-macro = { path = "../../" } [[bin]] name = "include"@@ -6,7 +6,7 @@ version = "0.1.0" edition = "2024" [dependencies]-htmlmacro = { path = "../../" }+kaja-html-macro = { path = "../../" } [[bin]] name = "structmember"new file mode 100644@@ -0,0 +1,61 @@+// Copyright (c) 2026 Johan Mattsson+// License: MIT++use kaja_html_macro::html;++struct TestDataMessage {+ message: String,+ logged_in: bool,+}++struct TestData {+ data: TestDataMessage,+}++impl TestData {}++fn login_form(data: &TestDataMessage) -> String {+ let content = html! {{+ <h1>Form: $(&data.message)</h1>+ }};++ content+}++fn get_inner_html(data: &TestDataMessage) -> String {+ let content = html! {{+ <rust>+ if !data.logged_in {+ <markup>+ <include login_form(&data) />+ </markup>+ }+ </rust>+ }};++ content+}++#[test]+fn include_inner_html() {+ let test = TestData {+ data: TestDataMessage {+ message: "test data".to_string(),+ logged_in: false,+ },+ };++ let content = html! {{+ <include login_form(&test.data) />+ }};++ assert!(content.contains("test data"));+ assert!(content.contains("Form"));++ let content = html! {{+ <include get_inner_html(&test.data) />+ }};++ println!("Generated: {}", content);+ assert!(content.contains("Form"));+}