Skip to content

Can't access child's root level defined variables inside an inherited block #667

@zraymene

Description

@zraymene

Describe the bug
Can't access child's root level defined variables inside an inherited block, either by let or decl.
I don't want to define the variables at struct definition level (it's rendering logic and i want to keep it in a template), nor inside the block because it gets computed once and shared between multiple block.

To Reproduce
Parent template

{% block title %}{% endblock %}

Child template

{% extends "parent.html.j2" %}

{% let test_variable = "Hello" %}

{% block title %} 
    {{- test_variable  -}} 
{% endblock %}

Error: no field 'test_variable' on type

Askama version
0.15.1

Rust version
rustc 1.90.0 (1159e78c4 2025-09-14

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