Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit cbddeda

Browse files
committed
test: partial render with block fragments
1 parent 03690ab commit cbddeda

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

testing/tests/block_fragments.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,22 @@ fn test_fragment_unused_expression() {
8181

8282
assert_eq!(unused_expr.render().unwrap(), "\n\n<p>Required</p>\n");
8383
}
84+
85+
/// Tests rendering a block fragment that inherits a template.
86+
/// Only the block, i.e. the partial content, should be rendered.
87+
#[derive(Template)]
88+
#[template(path = "child.html", block = "content")]
89+
struct Partial<'a> {
90+
title: &'a str
91+
}
92+
93+
#[test]
94+
fn test_partial_render() {
95+
let t = Partial {
96+
title: "the title"
97+
};
98+
assert_eq!(
99+
t.render().unwrap(),
100+
"(the title) Content goes here"
101+
);
102+
}

0 commit comments

Comments
 (0)