Why if block does not work inside another block
HosMercury opened this issue · comments
Hos.Mercury commented
I have this code :
<div id="content d-flex justify-content-center align-items-center">
{% block content %}
{# flash messages #}
{% if let Some(message) = message %}
<span class="bg-danger text-white d-flex justify-content-center container-fluid">
<strong class="">{{ message }}</strong>
</span>
{% endif %}
{% endblock %}
</div>
The part commented flash messages
does not show inside the block unless I moved it outside the bloc like this :
<div id="content d-flex justify-content-center align-items-center">
{# flash messages #}
{% if let Some(message) = message %}
<span class="bg-danger text-white d-flex justify-content-center container-fluid">
<strong class="">{{ message }}</strong>
</span>
{% endif %}
{% block content %}
{% endblock %}
</div>
what If wanted it like the first example code inside the block ?
Dirkjan Ochtman commented
Is this at the top level of your template? Where is the message
value coming from?
Hos.Mercury commented
yes it is the base templ
Hos.Mercury commented
Is this at the top level of your template? Where is the
message
value coming from?
yes
Dirkjan Ochtman commented
This probably has something to do with the inheritance setup, but it's hard to say for sure without more context (like your type definitions -- ideally, a full reproducible example).