tornadoweb / tornadoweb/tornado

Module importing in templates must be block-local

Open
#275 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

template
Dominant language
Python
Stars
22.2k
Forks
5.6k
Avg merge
3h 42m
Merged PRs (30d)
16

Description

Modules imported with {% import <module> %} outside a block cannot be used inside it - they must be imported within its scope. I would expect imports at file scope to be available to all blocks.

{% import os %}
{{os}} {% comment "works" %}
{% block "block" %}
    {{os}} {% comment "error" %}
    {% import os %}
    {{os}} {% comment "works" %}
{% end %}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating Tornado's template handling for {% import %} and {% block %} scope, then reproduce the behavior with the template shown in the issue. Done means an import at file scope is available inside blocks while block-local imports continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.