Skip to content

Instantly share code, notes, and snippets.

@colinta
Created March 16, 2012 17:07
Show Gist options
  • Save colinta/2051179 to your computer and use it in GitHub Desktop.
Save colinta/2051179 to your computer and use it in GitHub Desktop.
I wish jinja2 could extend blocks.
<!doctype html>
<title>{{ title or "My Title" }}</title>
<body>
{% block headers %}{% endblock %}
{% block content %}{% endblock %}
</body>
{% extends "base.html" %}
{% block headers %}
<h1>{% block headers %}{% end block %}</h1>
{% end block %}
<!doctype html>
<title>BAH</title>
<body>
<h1>Hi!</h1>
<p>my content</p>
</body>
{% extends "headers.html" %}
{% set title="BAH" %}
{% block headers %}
Hi!
{% endblock %}
{% block content %}
<p>my content</p>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment