Clone in a terminal:
Commit bd2bcc8
Johan Mattsson - 2026-06-13T22:36:51+00:00
bd2bcc83b843b461be34301cd703867aa0068cb5johan.mattsson.m@gmail.com

Fix space after variable

Changed files (2)

Diff

diff --git a/src/htmlquotes.rs b/src/htmlquotes.rsindex aaee939..cd704d1 100644--- a/src/htmlquotes.rs+++ b/src/htmlquotes.rs@@ -69,6 +69,11 @@ impl<'a> HtmlQuotes<'a> {                 let variable_tokens = self.process_variables()?;                 self.result.push_str(variable_tokens.as_str());                 self.current_index += 2; // advance past $ identifier++                if self.current_index > 0 {+                    let last = self.get(self.current_index - 1).unwrap();+                    pass_through.push_str(last.white_space_after.clone().as_str());+                }             } else {                 pass_through.push_str(current_value.to_string().as_str());                 self.current_index += 1;diff --git a/tests/other.rs b/tests/other.rsindex 0cc2f3f..5d2d20f 100644--- a/tests/other.rs+++ b/tests/other.rs@@ -1,6 +1,9 @@ // Copyright (c) 2026 Johan Mattsson // License: MIT +#[cfg(test)]+use std::time::Duration;+ use kaja_html_macro::html;  #[test]@@ -270,3 +273,34 @@ fn test_script_string_compiles() {      assert!(content.contains("bird")); }++#[test]+fn test_space_after_var() {+    pub struct Task {+        title: String,+        target_time: Duration,+    }++    let task = Task {+        title: String::from("Test Task"),+        target_time: Duration::from_secs(60),+    };++    let all_tasks = vec![task];++    let content = html! {{+        <rust>+            for task in &all_tasks {+                let minutes: u64 = task.target_time.as_secs() / 60;++                <markup>+                    <h2>$(task.title)</h2>+                    <p>Time to complete: $minutes minutes</p>+                </markup>+            }+        </rust>+    }};++    println!("Content {}", content);+    assert!(content.contains("1 minutes"));+}

Contact

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