Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test partial renders with block fragments #1032

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
target
Cargo.lock
.DS_Store
.idea
rellfy marked this conversation as resolved.
Show resolved Hide resolved
19 changes: 19 additions & 0 deletions testing/tests/block_fragments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,22 @@ fn test_fragment_unused_expression() {

assert_eq!(unused_expr.render().unwrap(), "\n\n<p>Required</p>\n");
}

/// Tests rendering a block fragment that inherits a template.
/// Only the block, i.e. the partial content, should be rendered.
#[derive(Template)]
#[template(path = "child.html", block = "content")]
struct Partial<'a> {
title: &'a str
}

#[test]
fn test_partial_render() {
let t = Partial {
title: "the title"
};
assert_eq!(
t.render().unwrap(),
"(the title) Content goes here"
);
}