Let's say I have a template called "template.njk":
{% block A %}
{% endblock %}
{% block B %}
{% endblock %}
And "page.njk" extends it:
{% extends "template.njk" %}
{# set a variable #}
{% set foo = "bar" %}
{% block A %}
{# use the variable #}
{{ foo }}
{# modify the variable #}
{% set foo = "baz" %}
{# I would now want this to "scope up" so I can use it in block B #}
{% endblock %}
{% block B %}
{{ foo }}
{# this now outputs "bar", but I want it to output "baz", how would I do that? #}
{% endblock %}
As I explained in the comments in the code, I wonder if there's a way to carry over the changed variable into the other block... Is that possible?
Let's say I have a template called "template.njk":
And "page.njk" extends it:
As I explained in the comments in the code, I wonder if there's a way to carry over the changed variable into the other block... Is that possible?