Skip to content

Block duplication detection seems to be overzealous #654

@Eijebong

Description

@Eijebong

If you extend a template that extends another, with blocks built on top of the previous one using {{ super() }}, askama emits warnings like this despite the behavior being "correct":

⚠️ templates/b.html:2:3: block `foo` was already called at `templates/c.html:3:3` so the previous one will be ignored

The following code:

templates/a.html

{% block foo %}{% endblock %}

templates/b.html

{% extends "a.html" %}
{% block foo %}
b
{{- super() -}}
{% endblock %}

templates/c.html

{% extends "b.html" %}

{% block foo -%}
c
{{- super() -}}
{% endblock %}

src/main.rs

use askama::Template;

#[derive(Template)]
#[template(path="c.html")]
struct X;

fn main() {
    println!("{}", X.render().unwrap());
}

Renders as:

[eijebong@plutonium] ~/code/askama_repro (main) >>> cargo run
⚠️ templates/b.html:2:3: block `foo` was already called at `templates/c.html:3:3` so the previous one will be ignored
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/askama_repro`
c
b

askama: 0.15.1
rustc: rustc 1.94.0-nightly (1107bbac4 2025-12-26)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions