Commit 2a6d2f5
Update examples
Changed files (2)
Diff
@@ -15,9 +15,9 @@ use kaja_html_macro::html; fn parent() -> String { let content = html! {{- <div>+ <section> <include child_component_simple_loop() />- </div>+ </section> }}; content }@@ -26,19 +26,17 @@ fn child_component_simple_loop() -> String { let content = html! {{ <h1>Hello From Nested Component</h1> - <div>- <ul>- <rust>- for i in 1..=3 {- let element_id = format!("list item {:?}", i);-- <markup>- <li>Simple $element_id</li>- </markup>- }- </rust>- </ul>- </div>+ <ul>+ <rust>+ for i in 1..=3 {+ let element_id = format!("list item {:?}", i);++ <markup>+ <li>Simple $element_id</li>+ </markup>+ }+ </rust>+ </ul> }}; content }@@ -47,17 +45,15 @@ fn child_component_simple_loop() -> String { ## Output ```html-<div>- <h1>Hello From Nested Component</h1>-- <div>+<section>+ <h1>Hello From Nested Component</h1>+ <ul>- <li>Simple list item 1</li>- <li>Simple list item 2</li>- <li>Simple list item 3</li>+ <li>Simple list item 1</li>+ <li>Simple list item 2</li>+ <li>Simple list item 3</li> </ul>- </div>-</div>+</section> ``` ## Variables and Functions in the Markup@@ -45,10 +45,23 @@ use proc_macro_error::proc_macro_error; /// }}; /// ``` ///+/// # Result+/// ```html+/// <div>+/// <h1>Header</h1>+/// <ul>+/// <li>List item 1</li>+/// <li>List item 2</li>+/// <li>List item 3</li>+/// </ul>+/// </div>+/// ```+/// /// ## Variables and Functions in the Markup /// /// - `$variable_name` – insert content of the variable and escape tags. /// - `$(get_value())` – insert string from the get_value function and escape tags.+/// - `$(self.something)` – insert value something from struct self and escape tags. /// - `$(x + 2)` – compute x + 2 and add the content to the html string, escaped if needed. /// - `<include some_other_component() />` – insert trusted HTML content from the function some_other_component, html tags are allowed. #[proc_macro_error]