Hello all,

I'm a little confused about how the template engine handles blocks in
child templates.
I always thought that if you define a block in a child template that
isn't defined in a template the child template extends, the block is
just rendered as-is.
Otherwise, you would have to define every block you intend to use in
the parent template, which doesn't really makes sense in my opinion;
especially if you want to include reusable apps that come with their
own templates.
Here for example, I would expect the child block to be rendered as
well as the HTML that is not contained inside a block. Instead, only
the block from the parent template is rendered.

parent.html:
{% block parent %}
<p>this is in parent.html, in block parent</p>
{% endblock %}

child.html:
{% extends "parent.html" %}
{% block child %}
<p>this is in child.html, in block child</p>
{% endblock %}
<p>this is in child.html, but in no block</p>

What wonders me even more is that if you have multiple levels of
inheritance, a block in a child template is only rendered if it is
defined in the top-most base template. This means that you have to
define all blocks you are ever going to use in your base template.
Is this really the intended behavior, that blocks in child templates
are only rendered if they have been defined in the top-most parent
template?

Thanks in advance and Best Regards,

Jesaja Everling

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to