From 74162b9453486a53a4de40bba905b4be31dcf3f0 Mon Sep 17 00:00:00 2001 From: Oscar Giles Date: Tue, 11 Jun 2024 21:48:39 +0100 Subject: [PATCH] Add a failing test for using include within a block fragment This does not render the include block when used as a fragment, causing the test to fail. I don't know if this is expected behaviour. --- testing/templates/fragment-include.html | 9 +++++++++ testing/tests/block_fragments.rs | 12 ++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 testing/templates/fragment-include.html diff --git a/testing/templates/fragment-include.html b/testing/templates/fragment-include.html new file mode 100644 index 00000000..fb7f6f8c --- /dev/null +++ b/testing/templates/fragment-include.html @@ -0,0 +1,9 @@ +{% extends "fragment-base.html" %} + +{% block body %} +{% include "included.html" %} +{% endblock %} + +{% block other_body %} +

Don't render me.

+{% endblock %} \ No newline at end of file diff --git a/testing/tests/block_fragments.rs b/testing/tests/block_fragments.rs index ae723b6d..e5204b08 100644 --- a/testing/tests/block_fragments.rs +++ b/testing/tests/block_fragments.rs @@ -103,3 +103,15 @@ fn test_specific_block() { let t = RenderInPlace { s1 }; assert_eq!(t.render().unwrap(), "\nSection: [abc]\n"); } + +#[derive(Template)] +#[template(path = "fragment-include.html", block = "body")] +struct FragmentInclude<'a> { + s: &'a str, +} + +#[test] +fn test_fragment_include() { + let fragment_include = FragmentInclude { s: "world" }; + assert_eq!(fragment_include.render().unwrap(), "\nINCLUDED: world\n"); +}