Created
April 19, 2011 16:48
-
-
Save issackelly/928783 to your computer and use it in GitHub Desktop.
Django Template {{ block.super }} example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Template: A.html | |
<html> | |
<head></head> | |
<body> | |
{% block hello %} | |
HELLO | |
{% endblock %} | |
</body> | |
</html> | |
# Template B.html | |
{% extends "A.html" %} | |
{% block hello %} | |
World | |
{% endblock %} | |
# Rendered Template B | |
<html> | |
<head></head> | |
<body> | |
World | |
</body> | |
</html> | |
# Template C | |
{% extends "A.html" %} | |
{% block hello %} | |
{{ block.super }} World | |
{% endblock %} | |
# Rendered Template C | |
<html> | |
<head></head> | |
<body> | |
Hello World | |
</body> | |
</html> |
Thanks a lot for the explanation
Thanx
very helpful! Thanx
Nice example, I created a simple working version. https://github.com/diek/superduper
Thanks. Helped me to understand it more clearly :-)
Yeah!
On line 36 why is it not HELLO World? If in the parent template the HELLO is in all caps?
On line 36 why is it not HELLO World? If in the parent template the HELLO is in all caps?
You are right, @scotth527!
{{ block.super }}
will render the same content present in the current block of extended template.
Thus, in this case, HELLO World
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Surely that's wrong??? Template C should inherit from template B other it won't work will it?