summaryrefslogtreecommitdiff
path: root/htmlua-parser/src/render.rs
diff options
context:
space:
mode:
authorgyoder <70408179+gyoder@users.noreply.github.com>2025-07-05 18:36:26 -0600
committergyoder <70408179+gyoder@users.noreply.github.com>2025-07-05 18:36:26 -0600
commit94267c681f8086d118a4e07a626b94c517d2648b (patch)
tree19b342ff9d64b5a4f1e0a89a5c9c5062b7c7ddc7 /htmlua-parser/src/render.rs
parent88b22b4e774c00344f8dad2d9eda6e1ff0491a6e (diff)
added test
Diffstat (limited to 'htmlua-parser/src/render.rs')
-rw-r--r--htmlua-parser/src/render.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/htmlua-parser/src/render.rs b/htmlua-parser/src/render.rs
index 58a8259..d50e934 100644
--- a/htmlua-parser/src/render.rs
+++ b/htmlua-parser/src/render.rs
@@ -189,6 +189,37 @@ mod tests {
}
#[test]
+ fn basic_lua_include() {
+ let page = r#"
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <title>Basic HTML Page</title>
+ </head>
+ <body>
+ <h1>Hello World</h1>
+ <p>This is a paragraph.</p>
+ <span><lua>
+ htmlua.println("Test from Lua!")
+ </lua></span>
+ <include path="comp1.html" />
+ </body>
+ </html>"#;
+ let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+ p.push("tests/components");
+ let document = kuchikiki::parse_html().one(page);
+ let d = execute_lua(expand_template(document, &p, None).unwrap()).unwrap();
+ let text = d.select_first("span").unwrap().as_node().text_contents();
+ println!("{}", d.to_string());
+ assert_eq!(text, "Test from Lua!\n");
+ assert!(d.select_first("lua").is_err());
+ let text = d.select_first("#inc1").unwrap().as_node().text_contents();
+ assert_eq!(text, "included1");
+ assert!(d.select_first("include").is_err());
+
+ }
+
+ #[test]
fn recursive_include() {
let page = r#"
<!DOCTYPE html>