Block assignment scope is different than inline assignment
See original GitHub issueI want to set a variable in a child template that will be rendered in the parent template. If I use block assignment, nothing is rendered. If I use inline assignment, it works as expected. I am using Jinja 2.8 with Python 2.
base.html
:
{{ content }}
bad.html
with block assignment, nothing rendered:
{% extends 'base.html' %}
{% set content %}
Hello, World!
{% endset %}
good.html
, renders correctly:
{% extends 'base.html' %}
{% set content = 'Hello, World!' %}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Common Scope Block Tasks - MATLAB & Simulink - MathWorks
Step-by-step procedures of common scope tasks, including logging data, sharing scope images, and display manipulation.
Read more >Variable declaration, intitialiation, assignment, and scope
Essentially this question is more about the hows and why's than the results. I know that scope is based on where the variable...
Read more >Demystifying JavaScript Variable Scope and Hoisting - SitePoint
This article will explain how JavaScript's scoping system works. You'll learn about the different ways to declare variables, the differences ...
Read more >Working with Blocks - Apple Developer
Blocks Can Simplify Concurrent Tasks. A block represents a distinct unit of work, combining executable code with optional state captured from ...
Read more >using statement - C# Reference | Microsoft Learn
The using statement causes the object itself to go out of scope as soon as Dispose is called. Within the using block, the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Got this problem too. Simple test:
Changed in 45b59b522a542c21611214b352df049a3b6dbcb4