djc / askama

Type-safe, compiled Jinja-like templates for Rust
Apache License 2.0
3.5k stars 221 forks source link

Include statement has no effect when used from a block fragment #1063

Closed OscartGiles closed 2 months ago

OscartGiles commented 5 months ago

When using a block fragment include statements don't seem to work.

See https://github.com/OscartGiles/askama/commit/74162b9453486a53a4de40bba905b4be31dcf3f0 for an example.

Is this intented behaviour or a bug?

djc commented 5 months ago

Do you get an error? What's the behavior you're seeing and how does it differ from the expected behavior?

OscartGiles commented 5 months ago

Yes sorry, the test fails with:

running 1 test
thread 'test_fragment_include' panicked at testing/tests/block_fragments.rs:116:5:
assertion `left == right` failed
  left: "\n\n"
 right: "\nINCLUDED: world\n"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test test_fragment_include ... FAILED

failures:

failures:
    test_fragment_include

I was testing out block fragments for a project and had this issue. I was able to reproduce with this test.

Askama is awesome by the way! Really enjoying working with it.

djc commented 5 months ago

Can you try if it works with #1054?

OscartGiles commented 5 months ago

I merged that in and it still doesn't work.

GuillaumeGomez commented 5 months ago

Can you provide the template source code please? It'll be useful to add it as a regression test as well.

OscartGiles commented 5 months ago

I've just created a PR with the failing test https://github.com/djc/askama/pull/1066

GuillaumeGomez commented 5 months ago

Thanks!