Skip to content

Commit

Permalink
Add failing test from issue 272
Browse files Browse the repository at this point in the history
Reported by Ciprian Dorin Craciun ([@cipriancraciun]) in issue [#272].

[#272]: <#272>
[@cipriancraciun]: <https://github.com/cipriancraciun>
  • Loading branch information
Kijewski committed Nov 26, 2024
1 parent e31f4e2 commit 66dac1d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions testing/templates/block_in_include_base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{%- block block_in_base -%}
block_in_base: from base!
{%~ endblock -%}

{%- include "block_in_include_partial.html" -%}
9 changes: 9 additions & 0 deletions testing/templates/block_in_include_extended.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{%- extends "block_in_include_base.html" -%}

{%- block block_in_base -%}
block_in_base: from extended!
{%~ endblock -%}

{%- block block_in_partial -%}
block_in_partial: from extended!
{%~ endblock -%}
3 changes: 3 additions & 0 deletions testing/templates/block_in_include_partial.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- block block_in_partial -%}
block_in_partial: from partial!
{%~ endblock -%}
32 changes: 32 additions & 0 deletions testing/tests/include.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,35 @@ fn test_include_macro() {

assert_eq!(template.render().unwrap(), "Hello, Alice!\nHowdy, Bob!");
}

// FIXME: <https://github.com/rinja-rs/rinja/issues/272>

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note test

Suspicious comment
#[test]
#[should_panic(expected = r#"assertion `left == right` failed
left: "block_in_base: from extended!\nblock_in_partial: from partial!\n"
right: "block_in_base: from extended!\nblock_in_partial: from extended!\n"#)]
fn block_in_include() {
#[derive(Template)]
#[template(path = "block_in_include_extended.html")]
struct TmplExtended;

#[derive(Template)]
#[template(path = "block_in_include_base.html", block = "block_in_base")]
struct TmplBlockInBase;

#[derive(Template)]
#[template(path = "block_in_include_partial.html", block = "block_in_partial")]
struct TmplBlockInPartial;

assert_eq!(
TmplExtended.render().unwrap(),
"block_in_base: from extended!\nblock_in_partial: from extended!\n"
);
assert_eq!(
TmplBlockInBase.render().unwrap(),
"block_in_base: from extended!\n"
);
assert_eq!(
TmplBlockInPartial.render().unwrap(),
"block_in_partial: from extended!\n"
);
}

0 comments on commit 66dac1d

Please sign in to comment.