Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jinja2 - Override block tag inside include?

Having trouble overriding a block tag inside my include.

I have

base.html

<div>
  {% include 'snippet.html' %}
</div>

snippet.html

<h1>{% block h1 %}{% endblock h1 %}</h1>

index.html

{% extends 'base.html' %}
{% block h1 %}Hello World{% endblock h1 %}

I'd expect it to render as:

<div>
  <h1>Hello World</h1>
</div>

But no such luck. Any ideas?

like image 807
anthony-dandrea Avatar asked Jan 24 '26 21:01

anthony-dandrea


1 Answers

Ended up just putting everything in base.html

like image 74
anthony-dandrea Avatar answered Jan 26 '26 13:01

anthony-dandrea